Python Fundamentals / Loops
Lesson 18 of 38
break and continue
break exits the loop immediately. continue skips the rest of this round and moves on to the next one.
Key points
- break: leave the loop
- continue: skip to next item
- Useful in search loops
for n in range(10):
if n == 5:
break
if n % 2 == 0:
continue
print(n) # 1, 3Quiz · +10 XP
What does continue do?
Log in to save progress and earn XP.