Python Control Flow

Control Flow in Python

Learn how to control the flow of your Python programs using conditional statements and loops.

If Statements

age = 18
if age >= 18:
    print("You are an adult")
else:
    print("You are a minor")

Loops

For Loop

for i in range(5):
    print(f"Count: {i}")

While Loop

count = 0
while count < 5:
    print(f"Count: {count}")
    count += 1