What does indentation mean?
The spaces at the start of a line. In Python indentation is not decoration: the lines indented under an if, a loop or a def are the block that belongs to it.
In a lesson
Until now every program has been a flat list: one line after another. Real programs have structure: some lines belong together as a group, and the group runs only sometimes, or runs many times. Python shows those groups with indentation, the spaces at the start of a line. This lesson is about that, before the rest of the module uses it for real.
Learn it
- Taught in F2.1 Blocks and indentation Decisions and loops, GCSE
Used in
- F1.5 Comments and readable code
- F2.4 Nested selection and match
- F2.5 Count-controlled loops: for
- F4.1 Writing functions
- F5.3 Pseudocode and the exam reference language
- F6.6 The IDE
- F13.3 Pseudocode in the exam
- 0.3 Doing it again
- 0.4 Deciding
- 0.6 Lists of readings
and 7 more lessons.
Do the lesson in the simulator