Python Python Basics All Together Now Handle Exceptions

Invalid Literal error

TICKET_PRICE = 10

tickets_remaining = 100  

while tickets_remaining >0:
    print("tickets remaining are {}".format(tickets_remaining))
    name = input("Please, enter your name  ")
    Number = (input("{}, how many tickets would you like to buy  ".format(name)))
    try:
        number = int(number)
    except ValueError:
        print ("Try again")
    else:
        Price = TICKET_PRICE * Number
        print("Total price is {}".format(Price))
        option = input("Do you want to proceed (Y/N)?  ")
        if option.upper() != "N":
            print ("SOLD!")
            tickets_remaining -= Number
        else:
            print("Thanks {}".format(name))
print("Sold Out")

error showing up when a word is entered for the number tickets requested.

1 Answer

<noob />
<noob />
16,316 Points

format ur code it’s very difficult to track the problem

got the solution.