Python Python Basics All Together Now Branch and Loop

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
187,287 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.

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
187,287 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
187,287 Points

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