# Stack Trace

> The crash report. It lists each function call that led to the error.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** Traceback, Backtrace

## Think of it like

Think of it like footprints in snow. You follow them back to see where someone went.

## Definition

A stack trace is the report a program prints when it crashes. It lists the chain of function calls that led to the error, one per line. Each line names the file, the line number and the function. In Python the last line names the error, and the line above it is where it happened. Reading from the bottom up is the quickest way to the cause.

## Example

Emma's app crashes and prints a stack trace. Its last two lines point to line 2 of average and a ZeroDivisionError.

## Example code

```python
Traceback (most recent call last):
  File "st.py", line 4, in <module>
    print(average([]))
  File "st.py", line 2, in average
    return sum(scores) / len(scores)
ZeroDivisionError: division by zero
```

Read from the bottom. The error is last, and the line above it is where it broke.

## Why it matters

A stack trace turns "it crashed" into a file and a line number. It is the first thing to read when something breaks.

## Common mistake

Being scared off by the length. Start at the bottom; the answer is usually in the last few lines.

## Three principles

- **A chain of calls.** Each line is one step toward the crash.
- **File and line.** It says exactly where to look.
- **Bottom first.** In Python, the cause sits at the end.

## Related terms

- [Runtime Error](https://learn.benibix.com/term/development/runtime-error)
- [Exception](https://learn.benibix.com/term/development/exception)
- [Debugging](https://learn.benibix.com/term/development/debugging)
- [Function Call](https://learn.benibix.com/term/development/function-call)
- [Logging](https://learn.benibix.com/term/infrastructure/logging)

## Taught in

- [Exceptions and Debugging](https://learn.benibix.com/learn/development-concepts/exceptions-and-debugging): Programming Basics, 16/18

---

Source: https://learn.benibix.com/term/development/stack-trace
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.
