CodeAgeBy Sitezack
Python for Builders — Level 3Decisions and repetitions0 XP
Chapter progress0/6

Lesson 6 of 7

break: stop the loop

break ends the loop immediately — handy once you've found what you were looking for.

Without break, the loop would keep running to the end of the list for nothing.

for n in [2, 9, 4]:
    if n == 9:
        print("Found it!")
        break

🎯 Your mission

In numbers = [4, 9, 15, 2], find the first number strictly greater than 10: store it in found, stop the loop with break, then print found.

PRO lesson

This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.

Discover PRO