Troubleshooting Errors
Inevitably, you’ll run into trouble with your code, and you’ll need to
track down and squash a bug. The IDLE interactive mode can be
your friend; the Debug menu provides several tools that will help
you understand how your code is actually executing. You also have
the option of seeing all your variables and stepping through the ex-
ecution line by line.
Syntax errors
are the easiest to deal with; usually, this is just a typo
or a misunderstood aspect of the language.
Semantic errors
—
where the program is well-formed but doesn’t perform as expect-
ed—can be harder to figure out. That’s where the debugger can
really help unwind a tricky bug. Effective debugging takes years to
learn, but here is a quick cheat sheet ...