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

Dan B
Dan B
6,155 Points

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

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

got the solution.