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 trialvictorvillaplana
11,582 PointsTickets remaining don't reset after running the code
Hello! I ran my code until the tickets were sold out. Now, when a try to run the program again in the console, I always see that the tickets are sold out in the first step! I can't re-start the program to try to catch the exceptions. What should I do? Thanks in advance for your help!
3 Answers
Trevor J
Python Web Development Techdegree Student 2,107 PointsIt’s because you have while tickets_remaning <= 1:
.
It’s should be while tickets_remaning >= 1:
victorvillaplana
11,582 PointsHello!
Here is my code with the right format.
Thanks!!
TICKET_PRICE = 10
tickets_remaining = 100
while tickets_remaining <= 1:
print("There are {} tickets remaining in this moment".format(tickets_remaining))
user_name = input("What's your name? ")
number_of_tickets = input("Hello, {}, how many tickets would you like? ".format(user_name))
number_of_tickets = int(number_of_tickets)
total_price = number_of_tickets * TICKET_PRICE
print("The total due is ${} ".format(total_price))
confirmation = input("Do you want to proceed? (Y/N) ")
if confirmation.lower() == 'y':
print("Sold!")
tickets_remaining -= number_of_tickets
#TODO: Gather credit card information and process it.
else:
print("Ups! You canceled the purchase process. Thank you anyways, {}. See you soon!! ".format(user_name))
print("Sold out! Sorry, there are no tickets available ")
victorvillaplana
11,582 PointsThanks!!
Steven Tagawa
Python Development Techdegree Graduate 14,438 PointsSteven Tagawa
Python Development Techdegree Graduate 14,438 PointsYou'll have to format your code so we can see how everything is indented... Your workspaces are private, so that link won't work for anyone except you.