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 trial
Zean-Xuen Thong
2,246 PointsHelp on ValueError as err:
import math
def split_check(total,number_of_people):
if number_of_people <= 1:
raise ValueError("More than one people is need to split the the check")
cost_per_person = math.ceil(total / number_of_people)
return cost_per_person
try:
total_due = float(input("What is the total? "))
number_of_people = int(input("How many people? "))
amount_due = split_check(total_due, number_of_people)
except ValueError as err:
print("Oh no! That's not a vaild value! Try again....")
print("({})".format(err))
else:
print("EACH PERSON OWES ${}".format(amount_due))
Its supposed to do this:
What is the total? 1
How many people? 1
Oh no! That's not a vaild value! Try again....
"More than one people is need to split the the check"
Not:
What is the total? 1
How many people? 1
Oh no! That's not a vaild value! Try again....
Travis Alstrand
Treehouse TeacherHey Zean-Xuen Thong 👋
I edited your post to use markdown as Steven mentioned in his comment here. I would definitely check out the links he provided for future posts in the forum here. It is really important with Python as he mentioned.
I'm not actually seeing anything wrong here though. Can you please provide a link to this challenge so I can test things on my end? It may be asking for something specific that is missing or different here as these code challenges are very picky in what it wants.
Steven Parker
244,138 PointsSteven Parker
244,138 PointsCode, particulary Python, is difficult to interpret unless properly formatted. Take a look at these videos about Posting a Question, using Markdown formatting to preserve the code's appearance, and particularly this one about sharing a snapshot of your workspace.