September 2013
Intermediate to advanced
350 pages
9h 38m
English
Broadly speaking, there are two kinds of errors in Python: syntax errors, which happen when you type something that isn’t valid Python code, and semantic errors, which happen when you tell Python to do something that it just can’t do, like divide a number by zero or try to use a variable that doesn’t exist.
Here is what happens when we try to use a variable that hasn’t been created yet:
| | >>> 3 + moogah |
| | Traceback (most recent call last): |
| | File "<stdin>", line 1, in <module> |
| | NameError: name 'moogah' is not defined |
This is pretty cryptic; Python error messages are meant for people who already know Python. (You’ll get used to them and soon find them helpful.) The first two lines aren’t ...
Read now
Unlock full access