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!
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

Dawid Bara
949 PointsDifferent solution of error handling
Hello, I solve error problem in different way then Craig. I raise exception as err, not like in the lesson ValueError twice. Is it correct? Regards Dawid
try: ticket_ammount = int(input("Hello {}, how many tickets do You want?: ".format(name))) if ticket_ammount > tickets_remaining: raise Exception("Sorry! We have only {} tickets".format(tickets_remaining)) except Exception as err: print(err) except ValueError: print("{}, You must type a number!!!".format(name))
1 Answer

Steven Parker
225,664 PointsWhen you have a generic exception handler, it should be the last one in the series. Otherwise, the specialized handlers (like the one here for ValueError) will never get a chance to run since the generic one will handle them also.
As long as you observe that rule, using a generic handler is OK.
Dawid Bara
949 PointsDawid Bara
949 PointsThank You!