Control Flow

Summary

A program’s control flow is the order in which its code executes. The control flow of a Python program is regulated by conditional statements, loops, and function calls. This section presents the if statement as well as the for and while loops. The if statement allows you to execute certain lines of code only if a condition is met, and the for and while loops will execute a block of code repeatedly. At the end of the section, the list comprehension (a way to construct lists that can serve as an efficient alternative to for loops) is introduced.