Python Python Basics All Together Now Handle Exceptions

Invalid Literal error


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)))
        number = int(number)
    except ValueError:
        print ("Try again")
        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
            print("Thanks {}".format(name))
print("Sold Out")

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

2 Answers

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

got the solution.

Dan B
Dan B
6,149 Points

Well why didn't you share the solution because many other people are having the problem Vaibhav Kalra...