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.

Daniel Skyes
1,122 PointsHow do you account for all exceptions?
After finishing this part of the course, an error was still present when we fed in a string instead of an integer. (for example "blue").
My code is exactly as it is in the video but Craig didn't check the final code with a string. My console would output:
Oh no, we ran into an issue. invalid literal for int() with base 10: 'blue'. Please try again
Any help is greatly appreciated.
Cheers
2 Answers

Claudia Xie
2,125 PointsWhat I did was remove the int() from the num_of_tickets input prompt first. I then checked if the response to the input contained all numbers. If it didn't, I raised a ValueError. Otherwise, I converted the response to int().
num_of_tickets = input('Hello, {}! How many tickets would you like?\n'.format(username))
if all(char.isdigit() for char in num_of_tickets) == False:
raise ValueError('Input is not a valid number.')
else:
num_of_tickets = int(num_of_tickets)

Steven Parker
215,984 PointsYou see that message because your program is handling the exception caused by the string input. Otherwise, the program would end instead of giving you the chance to "try again".
Bryan Land
10,269 PointsBryan Land
10,269 PointsI ran into this issue too, and this solution is really good, but its beyond the scope of this beginner course. I decided to break it down for everyone...
Hope this helps! It sure helped me to understand the all function!