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 Branch and Loop

Kevin Brender a Brandis
Kevin Brender a Brandis
1,382 Points

No tickets left, another option

So instead of the solution Craig used i imported sys and used this line and changed the remaining to 0

print("there are {} tickets remaining".format(tickets_remaining)) if tickets_remaining <1: print("Sorry better luck next time") sys.exit()

Also because normally the tickets would be updated behind the screen and not 1 person buying tickets in 1 page. I do understand the way Craig used it else it would be hard to test. Opinions?

1 Answer

Steven Parker
Steven Parker
231,275 Points

For this exercise, you have to assume that this page runs on a single kiosk that is the one and only place a purchase can be made. But you're quire right that in actual practice it's much more likely that simultaneous service would be available from multiple locations and the server would have to manage available tickets.

But that's a much more complicated application and would require techniques yet to be covered in future courses.