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 trialCassidy Louch
2,175 PointsWhere i .format(err) i just get "invalid literal for int() with base 10: 'blue' instead of how many tickets are left
I've rewatch the video a few times, and i just can't quite get what I'm doing wrong. here is the code: try: num_tickets = int(num_tickets) if num_tickets > tickets_remaining: raise ValueError("There are only {} tickets remaining".format(tickets_remaining)) except ValueError as err: print("Oh no, something seems to not be right. {}. Please try again".format(err)) else:
1 Answer
Steven Parker
231,248 PointsThere's nothing wrong, the code is doing exactly as should be expected.
The message showing the number of tickets left is only issued when the number requested exceeds the number available.
But if you enter a word instead of a number, the system generates an error when the "int" function is called (before that test is reached), and the message you are seeing is the appropriate system message for that situation.
Adam Raboch
7,193 PointsAdam Raboch
7,193 PointsCassidy, you are right. This error also occurred in the previous lesson where we learned to handle errors. I find it confusing that we are combining error messages in the code, but the output is less than satisfactory...