Control Flow
Break, Continue and Pass
for n in range(1, 10):
if n == 3:
continue # skip 3
if n == 6:
break # stop the loop at 6
print(n)Output
1 2 4 5
| Keyword | What it does |
|---|---|
break | Exits the loop immediately |
continue | Skips to the next round |
pass | Does nothing; a placeholder for code you'll write later |