Written by the Fiveable Content Team โข Last updated September 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated September 2025
Definition
Indentation refers to adding spaces or tabs at the beginning of lines of code to visually organize and structure it. In Python, indentation plays an important role in defining blocks of code within control structures like loops and conditionals.
A control structure determines how statements are executed based on certain conditions or criteria. Examples include if statements, loops (like for and while), and switch statements.
A syntax error occurs when code violates programming language rules or grammar. Incorrect indentation can lead to syntax errors because it affects how code blocks are interpreted.
Code Block: A code block refers to a group of statements that are grouped together and executed as a unit. Indentation is used to define the boundaries of code blocks in programming languages like Python.