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

Syntax error

i received this error File "masterticket.py", line 12
if number_of_tickets < tickets_remaining
^
SyntaxError: invalid syntax

why is this the case

TICKET_PRICE = 10

tickets_remaining = 100

while tickets_remaining >= 1: print("There are {} tickets_remaning.".format(tickets_remaining))
name = input("What is your name? ")
number_of_tickets = input(name + " how many tickets would you like to purchase? ") try: number_of_tickets = int(number_of_tickets) if number_of_tickets > tickets_remaining raise ValueError("There are only {} ticket remaining, nice try."format(tickets_remaining)) except ValueError as err: print("oh no, we ran into an issue {}, please try again".format(err)) else: total = number_of_tickets * TICKET_PRICE
print("Your total is {}".format(total))
proceed = input("{}, would you like to proceed with your purchase? Yes or No? ".format(name))
if proceed.lower() == "yes": print("SOLD!") print("Thank you very much {}, please come back soon.".format(name)) tickets_remaining -= number_of_tickets else: print("{}, thank you very much for your interest, please come back anytime.".format(name)) print("Sorry all sold out")

1 Answer

You are missing a colon at the end of your if statement. It should be

 if number_of_tickets > tickets_remaining: