continue in Python — Python Technical Interview Questions & Answers

continue in Python

continue in Python

  • continue skips the rest of this loop round and jumps to the next item. The loop does not end. Useful to ignore zeros, empty names, or a value you don’t want to print. for n in [1, 0, 2]: if n == 0: continue; print(n) → 1 then 2. Zero never prints, but 2 still does.
  • break would have stopped after zero and never printed 2. Same loop, two keywords, two outputs — that comparison is the viva.
  • continue in Python — output: 1, 2, 4, 5. 3 is skipped.

Technical Interview Tip: continue skips; break exits.

Code Examples for continue in Python

Example

# continue
for i in range(1, 6):
    if i == 3:
        continue
    print(i)

continue in Python — output: 1, 2, 4, 5. 3 is skipped.

How to Explain continue in Python to an Interviewer

Explain continue as if you are teaching a junior — definition, then one tiny script.

Skip this round. Loop goes on. Filter bad values.

What does the example print, and why?

continue in Python — output: 1, 2, 4, 5

What mistake do freshers make with continue?

break exits completely.