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

Python Python Basics Functions and Looping Raising Exceptions

Ines Fazlić
seal-mask
.a{fill-rule:evenodd;}techdegree
Ines Fazlić
Python Web Development Techdegree Student 9,569 Points

Error explanation in parenthesis

When I run the full code from this video and input 1 or less as the number of people, it runs as it should, but when I input a word as total due,like we did in the last video, I get this:

python check_please.py
What is the total? twenty
Oh no! That is not a valid value. Try again...
(could not convert string to float: 'twenty')

So, why am I getting the last line and how to get rid of it?

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Ines!

That is happening for any ValueError because we are printing the exception. The coercion of the word '"twenty"` is a ValueError.

My output would look the same, I just didn't run it again.

Does that answer your question?