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

brandon supinski
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
brandon supinski
Python Development Techdegree Graduate 27,983 Points

How would you get it so sold out message doesn't appear for the user who buys last ticket?

How would you get the sold out to not show for person purchasing X amount of tickets while X amount are available.

Trying to figure out how to get it to once its sold out, it still prompts for name but replies with, Sorry (NAME) the event is sold out.

(hopyfully im not jumping ahead and its fixed in next)

2 Answers

Steven Parker
Steven Parker
231,268 Points

Since this simple program always begins with a constant number of tickets, you could simply remove the "sold out" message "print" statement completely to prevent the last person from seeing it. You could also change the message to say something like "Thanks for purchasing the last ticket" instead, since you know it will only be shown after the last ticket is purchased.

brandon supinski
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
brandon supinski
Python Development Techdegree Graduate 27,983 Points

So due to this being a more simple program, with how its currently set up. Would we not be able to have a message to people trying to purchase when its sold out and a message to the person buying last ticket?

Thank you for the quick response by the way, staff and videos have just been amazing thus far.

Steven Parker
Steven Parker
231,268 Points

As the program works now, once the ticket supply is exhausted the program ends, so there's no opportunity to try to purchase when sold out.

Shiming Zhang
Shiming Zhang
829 Points

Why the tickets_remaining still large than 1, it prints "Sorry the tickets are all sold out."

Steven Parker
Steven Parker
231,268 Points

Your code might be different from Brandon's. Make a fresh question and include a link to a snapshot of your workspace.