Python requires every compound statement header, meaning a line ending in a colon such as if, elif, else, while, for, def, class, try or except, to be followed by at least one indented statement. Sometimes you have nothing to put there yet, or you deliberately want nothing to happen. Leaving the block empty is a syntax error: IndentationError: expected an indented block. A comment does not help, because the interpreter discards comments and the block is still empty.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 5 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.