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 trialMovrard Herard
Courses Plus Student 543 Pointshttps://w.trhou.se/nts7fi3e6k Oh no something went wrong.invalid literal for int() with base 10: 'blue'.
I cant understand where i went wrong. It may be my first imposter syndrome moment.
3 Answers
Ray Karyshyn
13,443 PointsI'm unsure where you think you went wrong. When you enter 'blue' in for the amount of tickets needed, the try
block catches a ValueError
and runs the except
block. You should get an error.
try:
tickets_wanted = int(tickets_wanted) # passing 'blue' returns a ValueError
except ValueError as err:
# inserts python's error message into your custom message
print("Oh no something went wrong. {}. Please try again".format(err))
Movrard Herard
Courses Plus Student 543 PointsThanks for the answer and sorry for my late reply. Im assuming i didnt save before attempting to run it again. Thanks again
Kyle Lewis
463 PointsI ran into this problem as well. The problem arises because we have two different exceptions being raised as the same ValueError. In the exception block, the line 'print("({})".format(err))' is giving you the grief. It is made to spit out the exception text that was thrown and it dose not discriminate on which exception it was. Its good for when we raised the custom exception about not having enough tickets remaining. But when you try to use anything but an integer when inputting amount of tickets to buy, it also will spit out the exception you are now witnessing. In order to fix this issue, I had to make a custom exception named InvalitTicketsRemaining and add and extra exception block.