# Indentation

> The space at the start of a line. It shows which lines sit inside a block.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** Indent, Code Indentation, Tabs vs Spaces

## Think of it like

It is like a list with dots. The lines pushed in belong to the line above.

## Definition

Indentation is the space at the start of a line of code. It shows which lines belong inside a block. In most languages it only helps people read. In Python it is part of the rules, and wrong spacing is an error. Python's style guide asks for 4 spaces per level.

## Example

Jack's Python code fails with an IndentationError. One line has 3 spaces instead of 4, so it does not line up.

## Example code

```python
for name in names:
    print(name)
print("done")
```

The pushed-in line runs for each name. The last line runs once, after the loop.

## Why it matters

Good indentation shows the shape of the code at a glance. In Python, it decides what the code does.

## Common mistake

Mixing tabs and spaces. They can look the same on screen, and Python refuses to run the mix.

## Three principles

- **Shows nesting.** Deeper lines sit inside outer ones.
- **Rule in Python.** Wrong spacing is an error there.
- **Pick one style.** Spaces or tabs, never both.

## Related terms

- [Code Block](https://learn.benibix.com/term/development/code-block)
- [Python](https://learn.benibix.com/term/development/python)
- [Code Style Guide](https://learn.benibix.com/term/development/style-guide)
- [Code Formatter](https://learn.benibix.com/term/development/formatter)
- [Syntax Error](https://learn.benibix.com/term/development/syntax-error)

## Taught in

- [Code Blocks and Indentation](https://learn.benibix.com/learn/development-concepts/code-blocks-and-indentation): Programming Basics, 4/18

![Three boxes, one inside the next. The outer box is a codebase holding a project folder and many files. One file, cart.py, is a module. Inside it, the lines under an if sit pushed in by four spaces, and a bracket marks them as one code block.](https://learn.benibix.com/diagrams/dev7-code-parts.svg)

---

Source: https://learn.benibix.com/term/development/indentation
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-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
