Python Control Flow

Go Gocourse AI Updated 16 Aug 2026
1 min read ·Lesson 4 of 6
In this post

if, for and while — how Python chooses what to do next.

if, for and while — how Python chooses what to do next.

Choosing

Indentation marks the block, so how the code looks and what it means cannot disagree.

score = 72
if score >= 80:
    print("distinction")
elif score >= 50:
    print("pass")
else:
    print("retake")

Output:

pass

Repeating

A for loop walks a sequence directly rather than counting an index towards its length.

for word in ["read", "run", "repeat"]:
    print(word.upper())

Output:

READ
RUN
REPEAT

Next

Carry on to the next tutorial in the rail — it picks up where this one leaves off.

PythonControl Flow

0 Comments

Reviewed before they appear

No comments yet.

Python
On this page
On this page
Python 6 posts
See all
Topics
PythonControl Flow