Lesson 10 of 55
8 mins readPython Break & Continue Statements
In Plain English
Fine-tune loop execution using break to exit a loop immediately upon finding a target, and continue to skip to the next iteration.
Deep Dive: How It Works
break: Immediately exits the innermost enclosing loop block.
continue: Skips the remaining statements in the current iteration and advances the loop to the next item.
Core Rules to Remember

break for Early Exits: Stop scanning when a condition is met, preventing redundant calculations.

continue for Filtering: Bypass unwanted elements or edge cases cleanly.
Live Interactive Example
Hit Run Code to see it livePrime Finding and Filtering
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Output Console
Click "Run Code" to view the rendered output.
How it works: continue skips odds; break exits when 56 is reached.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Find First Multiple of 11
Write a loop over `1:50`.
If `n > 30` and `n % 11 == 0`, print `"Found: $n"` and `break`.
1
2
3
4
5
6
7
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.