Lesson 15: if — Making Decisions
The if statement runs a block only when a boolean condition is True. Lines indented (4 spaces) after the if belong to the block.
if x > 0: is like "if x is positive then…". Each indented line is part of the body.
- if
- A control structure: runs code if a condition holds.
- indentation
- The leading spaces that mark a block.