Back to Python Errors
Python Exception

NameError

Name is not defined

What does this error mean?

Occurs when trying to access a variable or function that hasn't been defined.

How to fix NameError?

Check if the variable is defined before using it. Verify spelling and scope.

Example
print(x) # NameError: name 'x' is not defined