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
200,784 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.