Solved – NameError: name is not defined
Posted on: March 07, 2021 by Ariessa Norramli
In this article, you will learn how to solve NameError: name is not defined.
Let’s look at a code example that produces the same error.
number = 5
print(num)
# Traceback (most recent call last):
# File "example.py", line 3, in <module>
# NameError: name 'num' is not defined
How to Solve NameError: name is not defined
In order to solve it, you need to make sure that the variable has been defined first before using it.
number = 5
print(number)
# 5
Share on social media
//