Python Python Basics All Together Now Branch and Loop

Alan Mariani
PRO
Alan Mariani
Pro Student 1,499 Points

SyntaxError: invalid syntax

Hi, I reviewed my code, debugging some parts and it keeps throwing SyntaxError. Follows my code below. Can someone help me?

TICKET_PRICE = 10

tickets_remaining = 100

Output how many tickets are remaining using tickets_remaining variable

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

Gather a user's name and assign it to a new variable

name = input("What's your name: ")

Prompt the user by name and ask how many tickets he/she would like

num_tickets = input("How many tickets would you like {} ?".format(name)) num_tickets = int(num_tickets)

Calculate the price (number of ticket multiplied by the price) and assign it to a variable

price = num_tickets * TICKET_PRICE

Output the price to the screen

print("The price is ${}".format(price))

Prompt user if they want to proceed ... Y/N

confirm_purchase = input("Would you like to proceed with the purchase? (Y/N) ")

If they want to proceed

If confirm_purchase.lower() == "y": #here SyntaxError occurs # Print out to the screen "SOLD" to confirm purchase print("SOLD!!")
# And then, decrement the number of tickets remaining by the number of tickets purchased tickets_remaining -= num_tickets

Otherwise

else: # Thank them by name print("Thank you {}".format(name)

Thanks in advance!!!

3 Answers

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,196 Points

if should have a lowercase i here:

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

You are also missing a closing parenthesis here:

print("Thank you {}".format(name))
Alan Mariani
PRO
Alan Mariani
Pro Student 1,499 Points

Thank you so much Kris. Most of the replies which I verified in the forum was mentioning that the error was because a lack of parenthesis in the previous sentence. I didn't realized it could be after in somewhere below in the code. Thank you so much again!!!

Marcos Duran
Marcos Duran
1,540 Points

Thank you as well!! Same issue!