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 trialAlvaro Arroyo
737 PointsWhats wrong with my code?
this is the code in question:
import math
def split_check(total,number_of_people):
if number_of_people <=1:
raise ValueError("Thats not a valid value")
return math.ceil
try:
total_due = float(input("What is the total?"))
number_of_people =int(input("How many people?"))
except ValueError as err:
print("Something went wrong!")
print("({})").format(err)
else:
amount_due = split_check(total_due,number_of_people)
print("you owe", amount_due, "euros")
1 Answer
Simon Sørensen
17,304 PointsYour problem is that in your function split_check, you're simply returning the math.ceil function without giving it a value to work out. If you change your line to divide the total by the amount of people, it works just fine;
return math.ceil(total / number_of_people)
Alvaro Arroyo
737 PointsAlvaro Arroyo
737 PointsThanks so much!