Every program has bugs, and finding them is a skill that improves with a method more than with cleverness. This lesson gives you the method: reproduce the problem, shrink it, form a guess about the cause and test the guess. Then it shows the tools, from the humble print statement to the pdb debugger that stops a running program and lets you look around inside it.
More lessons in Complete Python Programming