Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

Key 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
John Lack-Wilson
8,169 Points

Hi 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.