Programs make decisions. In Python, that starts with if.
Direct answer
A Python if statement runs a block of code only when a condition is true. Add elif to test more conditions and else for everything else. Indentation shows which lines belong to each block.
Basic example
age = 18
if age >= 18:
print("You can vote")
elif age >= 16:
print("Almost there")
else:
print("Too young")
Comparison operators
| Operator | Meaning |
|---|---|
== | equal to |
!= | not equal |
> < | greater, less than |
>= <= | greater or equal, less or equal |
Combining conditions
if age >= 18 and has_id:
print("Welcome in")
Use and, or and not to combine tests.
Common mistakes
- Using
=instead of==in a condition. - Forgetting the colon at the end of the
ifline. - Mixing tabs and spaces for indentation.
Where Teyro fits
Teyro's Python for Beginners course turns this into short lessons you can play in a few minutes a day. It has 120 lessons, and you can start free.
The bottom line
Condition, colon, indented block. Practise with small examples until it feels natural.



