The easiest thing to do is put the following in your code somewhere:
import pdb; pdb.set_trace()
Then when you run it, it will stop there and you can step through the code a line at a time. The
l(ist) command will show you 11 lines of code around the current line is the one I use the most.
r(eturn) are some other I use regularly.
Once the debugger is up, you can check the stacktrace
w(where), variable values
[variable_name] or many other things. Please check the documentation or the cheatsheet image above.
A much more in-depth usage of pdb can be found here