Python Online Debugger
Find bugs in Python code without installing anything. Set breakpoints, step through your program line by line, step into functions, and watch the variables and the call stack change while it runs.
How to debug Python online
- Open the Python editor and write or paste your program, or open one of the examples below.
- Click beside a line number to set a red breakpoint. Set as many as you need.
- Select Debug. The program runs and pauses on the first breakpoint it reaches. If you switched the editor to Browser Python, switch back to Execution Server first: the debugger runs there.
- Read the Variables panel for the current values and the Call Stack panel for the functions that led to this line.
- Use Step Over to run the next line, Step Into to enter a function call, Step Out to finish the current function, or Continue to run to the next breakpoint.
- Select Stop when you have found the problem, fix the code and run it again.
What the debugger shows
- BreakpointsPause exactly where a value goes wrong instead of adding print() calls everywhere.
- Step by stepStep over, into and out of functions, and see which line runs next.
- VariablesThe variables of the function that is running, or the top-level variables outside a function, with their current values every time the program pauses.
- Call stackThe chain of function calls that reached the current line, which makes recursion easy to follow.
- Real Python, with input()Your program runs with real Python 3 on our execution server, the editor's default mode, so it can ask for keyboard input and import the installed libraries while you debug.
- AI helpAsk the AI to explain an error or suggest a fix, right in the editor.
Try it: why is the average wrong?
The average of 80, 72, 95 and 73 is 80, but the function returns 60.0. Set a breakpoint on the return line and select Debug: total is 240, not 320, because range(1, len(scores)) starts at the second item.
def average(scores):
total = 0
for i in range(1, len(scores)):
total += scores[i]
# Expected 80.0, but this prints 60.0.
# Set a breakpoint on the next line and look at total and i.
return total / len(scores)
print(average([80, 72, 95, 73]))
Follow recursion in the call stack
Set a breakpoint on return n * factorial(n - 1) and use Step Into. Each call adds a frame to the call stack with its own n. The second call, factorial(0), skips the base case and keeps going until Python raises RecursionError; the stack shows why.
def factorial(n):
if n == 1:
return 1
return n * factorial(n - 1)
# Step Into each call and watch the Call Stack grow, then shrink.
print(factorial(4))
# factorial(0) never reaches n == 1: debug it to see why it fails.
print(factorial(0))
Check a condition inside a loop
Pears are out of stock but still appear in the list. Put a breakpoint on the if line and press Continue to stop once per item: when count is 0, the condition is still true.
inventory = {"apples": 3, "pears": 0, "plums": 5}
in_stock = []
for name, count in inventory.items():
if count >= 0: # Bug: should be > 0
in_stock.append(name)
print("In stock:", in_stock)
Debugger, visualizer or print()?
| Tool | Best for |
|---|---|
| Debugger | Real programs: pause where it matters, inspect values, and control how the program continues. |
| Python visualizer | Learning: every step of a short program is recorded and drawn, with arrows from variables to lists and objects. |
| print() | A quick look at one value, or logging what a long-running program does. |
| AI code checker | An explanation of an error message and a suggested fix. |
Frequently asked questions
How do I debug Python code online?
Open the Python editor, click beside a line number to set a breakpoint and select Debug. The program pauses there, and you can step through it while the Variables and Call Stack panels show its state.
Do I need to install Python or an IDE?
No. You use the debugger in the browser and your program runs with real Python on our server, so it works on any computer, including Chromebooks and school laptops.
Can I step into functions?
Yes. Step Into enters the function called on the current line, Step Out finishes it and returns to the caller, and Step Over runs the line without entering it.
What is the difference between the debugger and the visualizer?
The debugger pauses a real program at breakpoints and lets you control it. The Python visualizer records every step of a short program and draws its frames and objects with arrows, which is better for learning how references work.
Is it free?
Yes. Debugging is free and does not need an account.