<jupyter_start><jupyter_text>Debugging **pdb** implements an interactive debugging environment for Python programs. It includes features to let you pause your program, look at the values of variables, and watch program execution step-by-step, so you can understand what your program actually does and find bugs in the logic.  Starting the Debugger **From the Command Line**<jupyter_code>def seq(n):
    for i in range(n):
        print(i)
    return

seq(5)<jupyter_output>0
1
2
3
4<jupyter_text>**From Within Your Program**<jupyter_code>import pdb

#interactive debugging
def seq(n):
    for i in range(n):
        pdb.set_trace() # breakpoint
        print(i)
    return

seq(5)


# c : continue
# q: quit
# h: help
# list
# p: print
# p locals()
# p globals()<jupyter_output>> <ipython-input-2-d5459efa1d5b>(7)seq()
-> print(i)
(Pdb) list
  2  	
  3  	#interactive debugging
  4  	def seq(n):
  5  	    for i in range(n):
  6  	        pdb.set_trace() # breakpoint
  7  ->	        print(i)
  8  	    return
  9  	
 10  	seq(5)
 11  	
 12  	
(Pdb) p i
0
(Pdb) p n
5
(Pdb) p locals()
{'i': 0, 'n': 5}
(Pdb) c
0
> <ipython-input-2-d5459efa1d5b>(6)seq()
-> pdb.set_trace() # breakpoint
(Pdb) list
  1  	import pdb
  2  	
  3  	#interactive debugging
  4  	def seq(n):
  5  	    for i in range(n):
  6  ->	        pdb.set_trace() # breakpoint
  7  	        print(i)
  8  	    return
  9  	
 10  	seq(5)
 11  	
(Pdb) p locals()
{'i': 1, 'n': 5}
(Pdb) c
1
> <ipython-input-2-d5459efa1d5b>(7)seq()
-> print(i)
(Pdb) p locals()
{'i': 2, 'n': 5}
(Pdb) c
2
> <ipython-input-2-d5459efa1d5b>(6)seq()
-> pdb.set_trace() # breakpoint
(Pdb) p locals()
{'i': 3, 'n': 5}
(Pdb) h

Documented commands (type help <topic>):
========================================
EOF    c          d        h   [...]
StarcoderdataJupyterStructuredCleanDedup