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 trial

Python Python Basics All Together Now Branch and Loop

Alan Mariani
PLUS
Alan Mariani
Courses Plus 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

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
PLUS
Alan Mariani
Courses Plus 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!!!

Thank you as well!! Same issue!