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 trialLuis Castillo
1,842 PointsMy code does not store the number of remaining tickets
TICKET_PRICE = 10
tickets_remaining = 100
Run this code continuosly until ticket run out
while tickets_remaining:
# Output how many tickets are remaining using the tickets_remaining variable
print("There are {} tickets remaining.".format(tickets_remaining))
#Gather the user's name ans assign it to a new varialble
name = input("What is your name? ")
#Promp the user by name and ask how many yickets they would like
tickets = input("Hello {}, How many tickets would you like? ".format(name))
tickets = int(tickets)
# Calculate the price (number of tickets multiplied by the price and assign it to avariable
total_price_tickets = tickets * TICKET_PRICE
# Output the price to the screEN
print("The total price would be {}".format(total_price_tickets))
#Promp user if they want to proceed. y/n?
should_proceed=input("Would you like to proceed y/n? ")
#IF they want to proceed
if should_proceed.lower == "y" :
# print out to the screen "SOLD!" to confirm purchase
#TODO: Gather credit card information and process it.
print("SOLD")
#and then decrement the tickets remaining by the number of tickets purchase
tickets_remaining -= tickets
#Otherwise..
else:
print("Thank you, {}".format(name))
print("The total price would be {}".format(total_price_tickets))
#thank them
notify there are no more tickets
print("Sorry the tickets are all sold out!!")
1 Answer
KRIS NIKOLAISEN
54,971 PointsThe lower method here:
if should_proceed.lower == "y" :
should be followed by parentheses like this
if should_proceed.lower() == "y" :