break vs continue in Python — Python Technical Interview Questions & Answers

break vs continue in Python

break vs continue in Python

  • Both change loop flow, but not the same way. break leaves the loop. continue skips only this round. Print 1..5, skip 3 → continue: 1 2 4 5. Stop at 3 → break: 1 2. Same for-loop, two keywords, two printed lines. That pair is the whole topic.
  • Don’t mix the words in the viva. “continue exits the loop” is a fail. One sentence each, then the 1..5 mental example.
  • break vs continue in Python — output: 1 then 3. 2 skipped, 4 breaks, 5 never runs.

Technical Interview Tip: Same loop, two keywords, two outputs.

Code Examples for break vs continue in Python

Example

# break vs continue
for i in range(1, 6):
    if i == 2:
        continue
    if i == 4:
        break
    print(i)

break vs continue in Python — output: 1 then 3. 2 skipped, 4 breaks, 5 never runs.

How to Explain break vs continue in Python to an Interviewer

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

Break exits loop Continue skips round

What does the example print, and why?

break vs continue in Python — output: 1 then 3

What mistake do freshers make with break vs continue?

Same sample → two outputs