NameError: name is not defined in Python

In this Python tutorial, we will discuss how to handle nameerror: name is not defined in Python. We will check how to fix the error name is not defined python 3.

NameError: name is not defined

In python, nameerror name is not defined is raised when we try to use the variable or function name which is not valid.

Example:

value = ['Mango', 'Apple', 'Orange']
print(values)

After writing the above code, Ones you will print “ values ” then the error will appear as a “ NameError: name ‘values’ is not defined ”. Here, the variable name values are spelled wrong, so we get this error.

You can refer to the below screenshot nameerror name is not defined python

nameerror name is not defined
NameError in python

To solve this nameerror: name is not defined python 3 we need to make sure that the variable name is spelled correctly.

Example:

value = ['Mango', 'Apple', 'Orange']
print(value)

After writing the above code, Ones you will print “ value ” then the output will appear as a “[ ‘Mango’, ‘Apple’, ‘Orange’] ”. Here, the correct variable name is ‘value’. So, in this way we solve the typo error in python.

You can refer to the below screenshot to remove the nameerror in python.

Python nameerror name is not defined
Python nameerror: name is not defined

You may like the following tutorials:

This is how to solve Python nameerror: name is not defined or NameError: name ‘values’ is not defined in python.