Python Python Basics All Together Now Cleaner Code Through Refactoring

Tlotlo Molokwe
Tlotlo Molokwe
4,743 Points

How to solve NameError: name not defined

Hi all i am having a problem with my code after creating the calculate_price function i receive a, NameError: name 'tickets_purchased' is not defined, when i try and run the program and input the number of tickets purchased by the user Imgur

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 49,702 Points

It looks like you have both tickets_purchased and ticket_purchased.

Change

ticket_cost = calculate_price(tickets_purchased)

to

ticket_cost = calculate_price(ticket_purchased)