Python Syntax
Indentation defines blocks, newlines end statements, and `#` starts a comment.
Beginner
if voltage > 5: # a colon opens a block
print("too high") # the block is indented (4 spaces by convention)
print("done") # back to the outer level
- One statement per line; a long expression can continue inside
(),[]or{}. - Names are case-sensitive:
Countandcountare different. - Style is guided by PEP 8 — tools like Ruff and Black apply it automatically.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.