Your first if statement is the moment your code starts to think.
First If teaches the one idea that turns a script into a program: making a decision. Plain English, real examples, no computer science degree required.
Three deep guides. Zero jargon walls. Read one on your lunch break.
age = 15
if age >= 18:
print("You can vote")
else:
print("Not yet - come back in a few years")The whole idea, in twenty seconds
An if statement is a code sentence that asks a yes/no question. If the answer is yes, a few lines run. If it is no, they are skipped. That is the entire concept — everything else is spelling.
Ask a question
A condition is any comparison that comes out true or false: age >= 18, pin == saved_pin, balance > price.
Run a block
Everything indented under the if belongs to it. If the answer is false, that block is skipped entirely and nothing inside it happens.
Add the other path
Add else and the program no longer has a silent gap: it does one thing or the other, always. That is a real decision.
Three guides, one skill
Written to be read in order, and useful on their own. Each one is built around the question beginners actually type into a search bar.
What Is an If Statement? A Beginner’s Guide to Conditional Code
What an if statement is, the three parts every one has, where conditions come from, and the five mistakes that catch almost every beginner.
Read the guide → Guide · 9 min readIf Else Statement: How to Make Your Code Choose a Path
How if else turns a skipped line into a real decision: else if chains, why branch order is logic, guard clauses instead of nesting, and the mistakes to avoid.
Read the guide → Guide · 9 min readHow to Write an If Statement: A Step-by-Step Method for Any Language
A four-step method for writing an if statement: state the rule, name the variable, choose the operator, test both paths — with the syntax for Python, JavaScript, Go and more.
Read the guide →Ask a question
Stuck on an exercise? Not sure why your code skipped a line? Send it over — a real answer beats another tutorial.
The most common thing we hear: “it works, but it never prints anything.” That is almost always a condition that was false when you thought it was true. Paste your code and we will point at the line.