Indentation

the whitespace that defines structure and brings code to life

Apr 09, 2026

Python Indentation

Python diverges significantly from other programming languages in its approach to code grouping. Instead of employing curly braces {} to define blocks of code, Python relies exclusively on indentation (utilizing either spaces or tabs). This practice is not merely a stylistic choice; it is a mandatory syntax requirement.

Example:

# Other languages use {} but Python uses indentation
if age > 18:
    print("You are an adult")   # indented = inside the if block
    print("You can vote")       # still inside
print("This is outside")        # not indented = outside the block

Incorrect indentation will lead to syntax errors and program failure. However, once mastered, this structure ensures the code remains exceptionally clean and readable.