Python Loop Control Statements
Satellite · Control Flow
Loop Control Statements
Fine-tune loop behavior with `break`, `continue`, `pass`, and `else` blocks.
Examples
for task in tasks:
if task.error:
break # stop processing
if task.done:
continue # skip
process(task)
else:
print("No errors encountered")
breakexits the loop immediately.continueskips to the next iteration.passis a no-op placeholder.
Use loop else blocks to detect when loops finish naturally (no break).