Python Syntax & Indentation
Most programming languages use curly braces { } to group blocks of code together. Python decided that looks messy and uses clean indentation (usually 4 spaces) instead. Clean spacing is not just cosmetic in Python: it is the law.
"Think of an outline or a bulleted list. When you indent a bullet point, it belongs to the heading above it. Python works the exact same way with code blocks."
Deep Dive: How It Works
In Python, indentation defines code structure. When you write an if statement, loop, or function, everything indented underneath belongs to that block.
The standard Python convention (PEP 8) is to use 4 spaces per indentation level. In ZenCompiler, pressing the Tab key inserts 4 clean spaces automatically.
Python is also case-sensitive. Variable names like "user", "User", and "USER" are three completely different variables to the interpreter.
Syntax Blueprint
if condition:
# 4 spaces of indentation
do_something()A colon : marks the start of a block, and the indented lines below it belong to that block.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
IndentationError: unexpected indentWhy it happens: Adding random spaces at the start of a normal line where no block was opened.
How to fix: Make sure standard top-level code starts at column 0 with no leading spaces.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Fix the Indentation
Fix the broken code so the greeting prints properly inside the block.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.