← back to unit
Medium
# basics loops
Skipping with continue
continue skips the rest of the current loop pass and jumps straight to the next one — the loop keeps going, it just skips one step:
for i in range(5):
if i == 2:
continue
print(i)
prints:
0
1
3
4
(only 2 gets skipped — the loop keeps running after it.)
Your turn: read a number n. Print every number from 0 up to (not including) n, except skip the number 3 using continue.
💡 need a hint?
pyb-loop-continue.py🔒 given lines are locked — write your code in between
loading...