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

gil shmuely
gil shmuely
1,644 Points

tickets will not subtract

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

TICKET_PRICE = 10
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
    else:
        print("Please let us know if you want to buy.")
print("SOLD OUT!") 

2 Answers

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

Steve.

gil shmuely
gil shmuely
1,644 Points

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?

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.