Python Syntax & Comments
Lesson Overview: Understand indentation blocks and single/multi-line comments.
Indentation Is Meaningful
Python uses consistent leading spaces (conventionally 4 spaces) to group statements under if, for, def, and class blocks. Comments begin with #.
- Consistent 4-space indentation avoids IndentationError
- Use # for inline comments and triple quotes for docstrings
Test Yourself With Exercises
Write a single-line Python comment before print():
Print greeting\nprint("Hi")