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

Eli Ato
Eli Ato
1,310 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

You are missing ')'

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

Ahh thank you lol couldn't see it

you are welcome!