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 trialSabry Salman
2,465 PointsKey Error - what does this mean
I was doing some practice on lesson on 'raising' errors and exceptions, but I noticed a new error called "key error" appearing
import math
def split_check (amount, people):
if attendees <= 1 :
raise ValueError("more that one person needed to split check")
return math.ceil(amount/people)
try:
value = float(input("how much? "))
attendees= int(input("how many? "))
amount_due = split_check (value, attendees)
except ValueError as err:
print ("oops, that wasnt expected")
print ("({ })".format(err))
else:
print ("the cost per person is" , amount_due)
import math
def split_check (amount, people):
if attendees <= 1 :
raise ValueError("more that one person needed to split check")
return math.ceil(amount/people)
try:
value = float(input("how much? "))
attendees= int(input("how many? "))
amount_due = split_check (value, attendees)
except ValueError as err:
print ("oops, that wasnt expected")
print ("({ })".format(err)) <------------------this line here
else:
print ("the cost per person is" , amount_due)
any help?
John Lack-Wilson
8,181 PointsJohn Lack-Wilson
8,181 PointsHi Sabry, its very difficult to debug your code in the way it is formatted. If you could either share your workspace or copy and paste the code in here in code formatting we may be able to help. You can do code formatting by typing three backticks (```) before and after your code.