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

Got "Traceback (most recent call last)" issue after added format(err) in the very end.

TICKET_PRICE = 10

tickets_remaining = 100

while tickets_remaining >=1:
    print("There are still {} tickets available".format(tickets_remaining))
    name = input("What's your name?   ")
    num_tickets = input("Hi {}! How many tickets would you like?   ".format(name))
    try:
        num_tickets = int(num_tickets)
        if num_tickets > tickets_remaining:
            raise ValueError("There are only {} tickets remaining".format(tickets_remaining))
    except ValueErrror as err:
         print("Oh no. {}. Please try again".format(err))
    else:
        total_due = num_tickets * TICKET_PRICE
        print("Total due is £{}".format(total_due))
        confirmation = input("Would you like to proceed {}? Y/N   ".format(name))
        if confirmation.lower() == "y":
            print("SOLD!")
            tickets_remaining -= num_tickets
        else:
            print("No worries")

print("Sorry, All SOLD OUT!")

Error:

There are still 100 tickets available                                                                                                  
What's your name?   Radek                                                                                                              
Hi Radek! How many tickets would you like?   10000                                                                                     
Traceback (most recent call last):                                                                                                     
  File "masterticket.py", line 12, in <module>                                                                                         
    raise ValueError("There are only {} tickets remaining".format(tickets_remaining))                                                  
ValueError: There are only 100 tickets remaining                                                                                       

During handling of the above exception, another exception occurred:                                                                    

Traceback (most recent call last):                                                                                                     
  File "masterticket.py", line 13, in <module>                                                                                         
    except ValueErrror as err:                                                                                                         
NameError: name 'ValueErrror' is not defined

1 Answer

Your error message shows what is wrong: NameError: name 'ValueErrror' is not defined. You have one too many r's in ValueError.

Damnnnn ... so stuid I amm haha Cheers Kris!