# Debuggers and Breakpoints

> How a debugger pauses your program on a breakpoint so you can look inside. When a print line or a rubber duck finds the bug faster.

**Course:** [Code Editors and Package Managers](https://learn.benibix.com/learn/development-tools)  
**Time:** 12 min

**After this lesson you can:**

- Set a breakpoint and step through code
- Find a bug with print lines
- Explain code out loud to find a slip

## How to stop a program and look inside

A debugger runs your program one step at a time. You mark a line with a breakpoint, and the program pauses just before that line runs. Then you can see the value of every name and step forward line by line. Python has had a built-in breakpoint() call since version 3.7, in 2018.

Most editors let you set a breakpoint by clicking beside the line number. A red dot appears. Run the program in debug mode, and it stops on the dot. A panel shows each value, and buttons step to the next line, step into a function, or carry on to the next breakpoint.

The point is to watch the values change. A bug is a place where a value is not what you thought. Stepping through shows you the exact line where a total turns into zero, or where a list loses an item.

Print debugging is the older way, and it still works well. You add lines that print values as the code runs. Run it, and read the output. The first value that looks wrong points at the bug. When it is fixed, you take the print lines out again.

Print lines are quick to add and work anywhere, even on a server with no editor. A debugger shows each value at once and leaves the code alone. Many people start with a print line. They reach for the debugger when the bug hides well.

Rubber duck debugging needs no tool at all. You explain your code out loud, line by line, to something that cannot answer, like a toy duck on the desk. To say what a line does, you have to read what it really does, not what you hoped. The gap between the two is often the bug.

Two mistakes are common. Leaving a breakpoint() call in code that goes live freezes the real app, waiting for a debugger. Leaving print lines in clutters the output and can leak private data into logs. Search for both before you commit.

```python
price = read_price()
print("DEBUG price:", price)
breakpoint()   # the program pauses here
total = price * qty
```
A print line shows one value. The breakpoint() call stops the program so you can look at all of them.

![Two panels on finding a bug without a debugger. Print debugging: four lines of code, two of them print lines that show the price and the total. Run it, and the output reads DEBUG price: 0, marked as the first wrong value, then DEBUG total: 0. Rubber duck debugging: three steps of a loop said out loud. Start at the first item, ok. Add each price, ok. Stop before length minus 1, marked skips one. A duck sits below and only listens.](https://learn.benibix.com/diagrams/left1-debugging.svg)

### Example: Jack's basket total is short

Jack's shop adds up 5 items in a basket, but the total always leaves one out. He reads the loop out loud to his desk duck, one line at a time.

At the third line he says it stops before the last item, and hears the bug. He changes one number, and the total is right.

**Words in this lesson:** [Debugger](https://learn.benibix.com/term/development/debugger), [Breakpoint](https://learn.benibix.com/term/development/breakpoint), [Print Debugging](https://learn.benibix.com/term/development/print-debugging), [Rubber Duck Debugging](https://learn.benibix.com/term/development/rubber-duck-debugging)

**Question:** What does a breakpoint do?

**Answer:** It pauses the program on that line so you can look at the values. The program stops just before the marked line runs. Then you can read every value and step on, one line at a time.

---

Source: https://learn.benibix.com/learn/development-tools/debuggers-and-breakpoints
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
