Indentation
Pronunciationin-den-TAY-shun
Definition
Indentation is the whitespace at the start of a line. In Python it is part of the syntax: it shows which lines belong to a block such as a loop or a function.
Where you hear it
In Python tutorials, error messages such as IndentationError, and style discussions about tabs versus spaces.
Examples
The body of the loop must be indented by four spaces.
Mixing tabs and spaces causes an indentation error.
The function body needs four spaces of indentation under the def line.
Common mistake
Mixing tabs and spaces in the same file. Pick spaces, four per level, and let your editor do it for you.
Don't confuse with
Braces { }, which other languages use to mark blocks. In Python the layout itself is the structure.
Say it at work
- In a meeting or chat
That line is off by one level of indentation, so it runs outside the loop.
- In an email or ticket
Configure the editor to insert four spaces when you press Tab.
Keep exploring
More in Programming Fundamentals