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 Python Basics Functions and Looping Raising Exceptions

Mark Chang
Mark Chang
5,214 Points

My code doesn't work

The output result is different from the video's i check my code again and again but I still couldn't find the problem.

My code (click "check_please.py" to open the code that i am asking): https://w.trhou.se/rxur115imd

result:

What is the total? 20
How many people? 0
Oh no! That's not a valid value. Try again...
Traceback (most recent call last):
File "check_please.py", line 12, in <module>
amount_due = split_check(total_due, number_of_people)
File "check_please.py", line 6, in split_check
raise ValueError("More than 1 person is required to split the check")
ValueError: More than 1 person is required to split the check

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "check_please.py", line 16, in <module>
print("({})".format(err))
NameError: name 'err' is not defined

1 Answer

Hi Mark, this is the clue: NameError: name 'err' is not defined, you forgot to add as err after the exception's name.