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

# I need help with the MasterTIcket (Try, Exception) I got stuck with a NameError

```TICKET_PRICE = 10

tickets_remaining = 100

service_charge = 2

def calculate_price(number_of_tickets):
return number_of_tickets * TICKET_PRICE + service_charge

while tickets_remaining >= 1:
print("There are {} tickets remaining.".format(tickets_remaining))
name = input("What is your name?  ")

try:
number_of_tickets = int(input("Hello!, {} How many tickets would you like?".format(name)))
if number_of_tickets > tickets_remaining:
raise ValueError("There are only {} tickets remaining".format(tickets_remaining))
except ValueError as err:
print("Oh No! That's not a valid value. {}. Please try again".format(err))

else:
total_price = calculate_price(number_of_tickets)
print("The total price is, \${}".format(total_price))
proceed = input("Are you sure you want to proceed with the purchase?\n Y/N?")
if proceed.lower() == "y":
print("SOLD!")
tickets_remaining -= number_of_tickets

else:
print("Thank you anyway, {}!".format(name))
print("Tickets are all sold out.")
```

Below the try: number_of_tickets If i write a non-integer value, it gives me a NameError, how do I fix that?

Thank you!!! :)

```if proceed.lower() == "y":