Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics All Together Now Branch and Loop

Eli Ato
Eli Ato
453 Points

Syntax error on variable subtraction

TICKET_PRICE = 10

tickets_remaining = 100


# Output tickets remaining

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

name = input("What is your name? ")

ticketsWanted = int(input("Hi {}, how many tickets would you like ?  ".format(name)))

price = ticketsWanted * TICKET_PRICE

print("That will be a total of ${}.".format(price))

confirmBuy = input("Would you like to confirm purchase of {} tickets? Y/N ?  ".format(ticketsWanted))

if confirmBuy.lower() == "y":
    print("SOLD, thank you for your purchase {}!".format(name)
    tickets_remaining -= ticketsWanted
else:
    print("Thank you anyways, {}".format(name))


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

I'm getting a syntax error on line 22 ( tickets_remaining -= ticketsWanted) Not sure why or what to do, I've tried seeing if it was something to do with indention to no avail. Thank you for any help!

2 Answers

Shem Ogweno
Shem Ogweno
12,657 Points

You are missing ')'

if confirmBuy.lower() == "y":
    print("SOLD, thank you for your purchase {}!".format(name)) #<-- Here --
    tickets_remaining -= ticketsWanted
Eli Ato
Eli Ato
453 Points

Ahh thank you lol couldn't see it