# Runtime Error

> An error that shows up while the program runs. Some input sets it off.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** Run-Time Error, Crash

## Think of it like

Think of it like a car that starts fine, then runs out of fuel on the road.

## Definition

A runtime error happens while the program is running. The code is written right, so it starts. Then it hits something it cannot do. Dividing by zero, opening a file that is not there and using a null value are common causes. The program stops at that line and shows a message. Often it only happens with certain input, so it can hide for a long time.

## Example

An average function works for weeks, then a class with no scores sends it an empty list. It crashes with ZeroDivisionError.

## Example code

```python
>>> scores = []
>>> sum(scores) / len(scores)
ZeroDivisionError: division by zero
```

The code is fine, but an empty list makes it divide by zero.

## Why it matters

Runtime errors often reach real users, because they hide until odd input comes along. Testing edge cases finds them first.

## Common mistake

Testing only with normal input. Try empty lists, zero, missing files and very long text too.

## Three principles

- **Starts, then stops.** The program runs until it hits the problem.
- **Depends on input.** Some values trigger it; most do not.
- **Test the edges.** Empty, zero and missing find it early.

## Related terms

- [Error](https://learn.benibix.com/term/development/error)
- [Syntax Error](https://learn.benibix.com/term/development/syntax-error)
- [Exception](https://learn.benibix.com/term/development/exception)
- [Stack Trace](https://learn.benibix.com/term/development/stack-trace)
- [Null](https://learn.benibix.com/term/development/null)

## Told apart from

- [Syntax Error vs Runtime Error](https://learn.benibix.com/compare/syntax-error-vs-runtime-error): A syntax error stops the code before a single line runs. A runtime error waits until the code hits a bad value.
- [Runtime Error vs Logic Error](https://learn.benibix.com/compare/runtime-error-vs-logic-error): People think a program that runs to the end with no message is working, and it may not be. A runtime error stops the program while it runs and names the line, such as a divide by zero. A logic error stops nothing. The program finishes and the answer is just wrong. Only a check of the result will catch it.

## Taught in

- [Bugs and Error Types](https://learn.benibix.com/learn/development-concepts/bugs-and-error-types): Programming Basics, 15/18

---

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