Python Break & Continue Statement Exercises

Let’s check out some exercises that will help understand Break and Continue statements better.

Exercise 10-a: Break statement inside a For Loop

Place a break statement in the for loop so that it prints from 0 to 7 only (including 7).


When the line with break statement is executed program exits that loop.

for i in range(100):
print(i)
if i == 7:
break

Exercise 10-b: If and Continue statements inside a For Loop

Add an if statement and a continue statement to the loop so that it skips when iterator equals "sun".


When the line with continue statement is executed program skips that iteration and goes back to where it left in the loop.

for i in weather:
if i == "sun":
continue
print(i)

Need More Exercises?

Check out Holy Python AI+ for amazing Python learning tools.

*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.
Umut Sagir
Finance & Data Science Professional,
Founder of HolyPython