
If Statements in Python
An if statement is how a Python program turns a condition into a decision: check something, then run one block of code or skip it. The whole skill is…
Read tutorialGive your programs decisions and repetition with conditions, loops, logical operators, and concise control-flow patterns.
Tutorials
Follow these lessons in order, or jump directly to the topic you need.

An if statement is how a Python program turns a condition into a decision: check something, then run one block of code or skip it. The whole skill is…
Read tutorial
You already know how to make a single decision with an if statement. Real programs rarely stop there. A login form checks that a user exists and that the…
Read tutorial
A for loop is how Python repeats an action for every item in a collection. You describe the action once, and Python runs it for each value in turn. That…
Read tutorial
A Python while loop is not a fixed counter. It is a repeating gate: Python checks a condition, runs the block while the condition is true, then checks…
Read tutorial
A loop repeats until something tells it to stop. break and continue are the two controls that decide what happens next: break exits the whole loop, while…
Read tutorial
Reading about if statements and loops is easy. Writing them is where you find out what you actually understand. That gap between recognizing a concept and…
Read tutorial
A single loop repeats one action. A nested loop repeats an action inside another repeated action—and that small shift is what lets you walk grids, tables,…
Read tutorial
A list comprehension is a compact way to build a new list by transforming or filtering an existing one. It is not a replacement for every loop—it is a tool…
Read tutorial
You know that feeling when you write a decision chain that keeps asking the same question about the same value? if status == 200, then elif status == 404,…
Read tutorial