When to use it
Use the debugger when a program runs but gives the wrong answer, when a loop does something unexpected, or when you want students to see how code executes.
Turn on the debugger
Select the bug button in the desktop toolbar, or open Menu β Debug β Enable Debugger on a phone or tablet. The editor gutter is now ready for breakpoints.
Set a breakpoint and run
Click a line number to set a breakpoint, then press Run. The program pauses when it reaches that line and highlights it. The Variables panel lists every value: choose Code for the variables you assigned, or All for everything visible.
total = 0
for number in [2, 4, 6]:
total += number # set a breakpoint here
print(total)
Step through
- Step Over runs the next operation and pauses again.
- Continue runs until the next breakpoint or the end of the program.
Watching total grow on each pass of the loop makes it obvious what the code really does.
Good to know
Breakpoints last for the current editor session. The debugger offers Step Over, not step-into or a full call stack. For syntax errors, or a crash before the breakpoint, read the console traceback first β it tells you the line and the reason.
Feature overview β