In the following lines, the first line is ok, and in the second line, "c" has never been filled with anything. Python is reading the lines, and when it reads the second line, says, "'c' is not defined", which means that 'c' was never filled and it does not know what it is.
a = 5
b = c
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-1-b58d3ea06324> in <module> 1 a = 5 ----> 2 b = c NameError: name 'c' is not defined
If the error is difficult to understand, many times the best thing to do is to search the internet. This means start a browser like Microsoft Edge, Internet Explorer, Google Chrome, or Firefox.
Then in the search box, add the name "python", and (copy and paste) the error like, "python name 'c' is not defined".
Since the "c" is only about this program, and the value could have been called 'd' or anything else, sometimes this needs to be removed from the search. So then it may be better to search for "python name is not defined".
Searching for errors is a very large part of programming, so do it often and you will get better at it.
A "syntax" problem means something about the letters is not correct. The "^" is showing where Python thinks the problem is.
a (&) g
File "<ipython-input-2-00c12674d0ab>", line 1 a (&) g ^ SyntaxError: invalid syntax
def func1()
a = 1
func1()
File "<ipython-input-3-b57592493260>", line 1 def func1() ^ SyntaxError: invalid syntax
def func1():
func2()
def func2():
b = c
func1()
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-4-a44e3f8f96f1> in <module> 5 b = c 6 ----> 7 func1() <ipython-input-4-a44e3f8f96f1> in func1() 1 def func1(): ----> 2 func2() 3 4 def func2(): 5 b = c <ipython-input-4-a44e3f8f96f1> in func2() 3 4 def func2(): ----> 5 b = c 6 7 func1() NameError: name 'c' is not defined
If you have not learned much programming yet, then don't worry too much about the Traceback yet. What it is trying to show is the path through the code to the problem. In this example, it went to the func1() and to the func2(), and then found a problem.
Sometimes a line of a program or a function in a program can be doing a lot of things that are difficult to understand.
a = 4
b = 2 + 5 * a / 'd'
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-5-a9136c2e1ede> in <module> 1 a = 4 ----> 2 b = 2 + 5 * a / 'd' TypeError: unsupported operand type(s) for /: 'int' and 'str'
Is the "* a" a problem?
2 + 5 * a
22
Nope, it is ok. Lets try a different part.
22 / 'd'
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-7-b7471189a4a5> in <module> ----> 1 22 / 'd' TypeError: unsupported operand type(s) for /: 'int' and 'str'
That shows the problem better. A divide symbol cannot be used with a number and a string.