The Python Language 3

Explore the main tools for control flow in Python.

Code blocks

In C-style languages, code blocks are indicated by curly braces {...}. In Python, we instead use a colon to introduce a code block, and all code inside that block must be indented consistently with at least one whitespace character.

Conditional execution

Like most languages, Python uses if / else constructs for conditional branching. Here, we branch using the Python boolean type, which can have values True or False.

Get hands-on with 1200+ tech skills courses.