Python Python Basics All Together Now Branch and Loop

tickets will not subtract

People, I don't know what am I doing wrong... Please let me know, thanks in advance!

tickets_remaining = 100

while tickets_remaining >= 1:
    print("There are {} tickets remaining.".format(tickets_remaining))
    username = input("Please enter your name: ")
    request = input("Hello {}, how much tickets would you like to buy?".format(username))
    request = int(request)
    price = request * TICKET_PRICE
    print("The price for {} tickets is {}".format(request, price))
    confirmation = input("Would you like to complete the purchase?")

    if confirmation.upper() == 'yes':
        print("You got it! {} tickets for for {} dollars!".format(request, price))
        tickets_remaining -= request
        print("Please let us know if you want to buy.")
print("SOLD OUT!") 

2 Answers

Steve Hunter
Steve Hunter
Treehouse Moderator 57,656 Points

Try changing 'yes' to 'YES'as you are converting confirmation to upper case.


Thank you, Steve, it worked... You really must pay attention to the smallest details when you are coding...

Is there an option to write both yes, and YES for confirmation?

John Goodwin
John Goodwin
17,919 Points

If you mean checking if confirmation is set to either "yes" or "YES," you could do this:

if confirmation in ("yes", "YES"):

But using .upper() or .lower() is considered cleaner and is more common.