## Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

# Branch and loop on tickets_remaining exercise

In the while loop, the codes still runs if the num_tickets is zero, is it supposed to run after we already specified it as >=1 ?

TICKET_PRICE = 10

tickets_remaining = 100

# Run this code continuosly until we run out of tickets

while tickets_remaining >= 1:
# Output how many tickets are remaining using the tickets_remaining variable. print("There are {} tickets left".format(tickets_remaining))

```# Gather the user's name and assign it to a new variable.
name = input("What is your name?  ")

# Prompt the user by name and ask how many tickets they would like.
number_of_tickets = int(input("Hey {}, how many tickets would you like?".format(name)))

# Calculate the price(number of tickets multiplied by the ticket_price) and assign it to variable
price = number_of_tickets * TICKET_PRICE

# Output the price to the screen
print("The ticket costs \${}".format(price))

# Prompt user if they want to proceed Y/N?
should_proceed = input("Do you want to proceed? Y/N  ".format(name))
# if they want to proceed
if should_proceed.lower() == "y":
# print out to the screen SOLD! to confirm purchase
print("SOLD!")
# and the decreament of the tickets remaining by the number of tickets purchased
tickets_remaining -= number_of_tickets
# Otherwise....
else:
# Thank them by name
print("Thank you {} for patronizing us".format(name))
```

# Notify the user that tickets are sold out

print("Hey {} the tickets are sold out".format(name))