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 Handle Exceptions

Invalid Syntax on subtraction equal assignment operator on tickets_remaining?

So my issue is with tickets_remaining -=

When I attempt to subtract the purchased tickets from my overall amount of tickets, it gives me an invalid syntax error at:

treehouse:~/workspace$ python masterticket.py
File "masterticket.py", line 27
tickets_remaining -= tickets
^
SyntaxError: invalid syntax
treehouse:~/workspace$

Anyone know a way around this?

3 Answers

If you want to share your workspace take a snapshot. It's the camera icon in the upper right corner.

Your syntax error is not on the line given but on the line before this:

print("SOLD! Thanks for confirming your purchase of {} ticket's".format(tickets) 

here you are missing the closing parenthesis of your print statement

print("SOLD! Thanks for confirming your purchase of {} ticket's".format(tickets)) 

You should review your use of parentheses in all of your print statements. There are a few where the parentheses are missing/in the wrong place.

You also have a variable 'should_proceed' but then check a variable 'proceed'. I made changes to these and others in the provided snapshot.

Awesome Kris, I really appreciate your help.

I've revised your changes and will definitely pay more closer attention.

Closing and +1

Hi!, your link is broken can u post again?

Really? It works fine for me.. https://teamtreehouse.com/workspaces/40629463

HI!, it saying page not found. can u format ur code in here?

you use 3 ```(pythpn)

<your code goes here>

and then 3 ```

TICKET_PRICE = 10

tickets_remaining = 100

# Run this code until tickets are gone

# Output how many tickets are remaining using the tickets_remaining variable
print("There are  {} tickets remaining.".format(tickets_remaining))

# Gather user 's name and assign it to a new variable
name = input("What's your name? ")

# prompt the user and ask how many tickets they 'd like
tickets = input("Hey {}! How many tickets would you like? ".format(name))
tickets = int(tickets)

# Calculate the price(Number of tickets multiplied by Ticket_Price)
ticket_sale = tickets * TICKET_PRICE

# Output the price to the screen
total = print("Your total will be ${}.00, enjoy the park!".format(ticket_sale))

# Prompt user if they want to proceed
should_proceed = input("Would you like to continue? (Y/N)? ")# If they want to proceed
if proceed.lower() == "y": #print out ot the screen "SOLD!"to confirm purchase
    print("SOLD! Thanks for confirming your purchase of {} ticket's".format(tickets) 
          tickets_remaining -= tickets 
          print("We now have {} ticket's remaining!").format(tickets_remaining)

    # and then decrement the tickets remaining by the number of tickets purchased 
    elif proceed == "N":
        print("That's unfortunate, here's your total of ${}.00 back").format(ticket_sale)

    # otherwise thank the user for using this application.
     else:
         print("Thanks for interacting with this application, {}").format(name)