Jan 26, 2026
# Chapter 4 — Conditions and Loops (With Common Mistakes First)
This chapter starts with mistakes, because that is how real learning feels.
## 4.1 Conditions
```python
age = 17
if age >= 18:
print("Adult")
else:
print("Minor")
```
### Mistake Pattern: Comparing the Wrong Thing
```python
text = "18"
if text >= 18:
print("Adult")
```
This fails because `"18"` is a string, not a number. Fix by converting:
```python
text = "18"
age = int(text)
print(age >= 18)
```
## 4.2 Loops (for and while)
### for loop
```python
for i in range(3):
print(i)
```
### while loop
```python
n = 3
while n > 0:
print(n)
n = n - 1
```
### Diagram: Loop Thinking
```text
start -> check condition -> run body -> change state -> check again -> ...
```
---