Control Flow and Built-in Functions

This lesson covers how the flow of execution transfers between lines of code depending on the scenarios. It also discusses some built-in functions for data structures studied in the previous lesson.

Control structures in Python #

The if-else construct #

If-then statements are a staple of any programming language. Basically, if you meet a certain condition, then something happens. In Python, elif stands for else if, meaning that if the previous conditions were not met, check that condition. Else is a catch-all condition for any remaining flows. Python follows the following syntax:

if condition:
  statements
elif condition:
  statements
else:
  statements

Following is a code example:

Get hands-on with 1200+ tech skills courses.