Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialdiginoma
Courses Plus Student 8,009 PointsCode works but the result is wrong. Running this code i use 5 for the number of ppl and 555. it returns 1 instead of 111
import math
def spli_check(total, number_of_ppl): cost_per_pers = math.ceil(total / number_of_ppl) return cost_per_pers
total = float(input("Please Input number of ppl ")) number_of_ppl = int(input("Please Input cost ")) amt_due = spli_check(total, number_of_ppl )
print("Each person owes ${}".format(amt_due))
1 Answer
Steven Tagawa
Python Development Techdegree Graduate 14,438 PointsYou have your inputs switched around. When you ask for the number of people, you're assigning it to the cost variable, and when you ask for the total cost, you're assigning it to the number of people variable.
diginoma
Courses Plus Student 8,009 Pointsdiginoma
Courses Plus Student 8,009 Pointsnvm... Figured it out. I assigned my variables incorrectly. Very messy code. will do better.