Skip to main content
Albero Academy

continue

Skip the rest of the current iteration and move to the next.

Flow Control6 min

continue skips the rest of the current iteration and jumps straight to the next one. Where break stops the loop, continue just abandons this item and carries on — perfect for filtering out cases you don't want to process.

Skipping items

skip the even numbers
for n in range(1, 8):
if n % 2 == 0:
continue # skip even numbers — go to the next n
print(n) # 1 3 5 7

The guard-clause pattern

continue keeps loops flat and readable by handling the "skip" cases up front, so the main logic isn't buried in deep indentation:

skip bad rows early
for row in rows:
if not row.strip():
continue # skip blank lines
if row.startswith("#"):
continue # skip comments
process(row) # the real work, un-indented

Key takeaways

  1. 01continue skips the rest of the current iteration and moves to the next.
  2. 02Use it to filter out cases you do not want to process.
  3. 03The loop keeps running — unlike break, which exits it.
  4. 04Guard clauses with continue keep the main loop body flat and readable.

Finished this chapter?

Mark it complete to track your progress through Python.