Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
210,424 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.