Problems

Python Problems

When something is entered on a line that Python does not understand, it will display some lines that try to describe the problem.

Most programming languages call these "Errors", but think of these as a chance to learn something new.

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.

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.

Traceback

In the example above, the problem had a simple error display. In many programs the error may have many lines.

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.

Simplify Problems

Sometimes a line of a program or a function in a program can be doing a lot of things that are difficult to understand.

Is the "* a" a problem?

Nope, it is ok. Lets try a different part.

That shows the problem better. A divide symbol cannot be used with a number and a string.