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 All Together Now Handle Exceptions

Johannes Bizimis
Johannes Bizimis
1,332 Points

Different solution

Hey, so I wrote working code that runs good, but I used a different way: Instead of saying: if numb_tickets > tickets_remaining: raise ValueError ..... I just said: if if numb_tickets > tickets_remainin: print(name, ", you selected too many tickets. There are only", tickets_remaining, "left for sale"). Is this also okay or is there only one right way here?

1 Answer

Steven Parker
Steven Parker
231,268 Points

In real life development, there is hardly ever a single "right" way to solve a programming problem. But you may be given certain criteria that have to be met in your code.

The point of this particular lesson is handling exceptions, so just printing a message without raising an exception doesn't address the purpose of this exercise.