Python Python Basics All Together Now Handle Exceptions

Syntax error

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

why is this the case


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

Pro Student 43,344 Points

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

 if number_of_tickets > tickets_remaining: