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

tickets

while tickets_remaining:

print("there are {} tickets remaining.".format(tickets_remaining))


ticket_buyer = input("What is your name: ")
if ticket_buyer == "gina":
    request = input("How many tickets would you like? ")
else:
    print("wait your turn")

purchased = int(request) * int(TICKET_PRICE)
print(str(purchased) + "$")

ticket_buyer = input( "Would you like to continue with purchase, yes or no:")

if ticket_buyer == "yes":
    print("SOLD!!!")
    purchased = int(tickets_remaining) - int(request)
    print(str(purchased) + " tickets remaining")

else:
    if ticket_buyer == "no":
        print("Thank you Charlotte")

print("sorry tickets are all sold out! ")

What's your question here Andrew?

basically with my while loop im trying to decrement the number of tickets remaining, by how many tickets are purchased; until it reaches zero but I cant seem to figure it out

1 Answer

Hello Andrew,

This should be fairly simple, just change the first line to something like:

while tickets_remaining > 0: 

You'll also need to define a value for tickets_remaining prior to your loop.

Is that what you're after, or did I misunderstand your query?