Python Python Basics All Together Now Branch and Loop

Luis Castillo
Luis Castillo
1,842 Points

My code does not store the number of remaining tickets


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.


    #and then decrement the tickets remaining by the number of tickets purchase
    tickets_remaining -=  tickets
    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

54,192 Points

The lower method here:

if should_proceed.lower == "y" :

should be followed by parentheses like this

if should_proceed.lower() == "y" :