compound statement
A statement such as if, for, while, def, class, try or with that has a heading ending in a colon and an indented block beneath it.
In more detail
The heading controls whether, how often or when the block runs. Forgetting the colon at the end of the heading is one of the most common syntax errors.
Related terms
- code block — The group of indented statements under a heading such as def, if, for or while, which run together as one unit.
- indentation — The spaces at the start of a line, which in Python decide which statements belong inside a def, if, for or other block.
- statement — One complete instruction in a program, such as an assignment, a function call on its own line, or an if statement.
Taught in
- Lists, Range And The For Loop — Hands-on Python: Complete Video Course & Book
- Repeat Loops And Successive Modification — Hands-on Python: Complete Video Course & Book
- Accumulation Loops — Hands-on Python: Complete Video Course & Book
- Mad Libs Revisited: Finding The Cues — Hands-on Python: Complete Video Course & Book