Skip to content
← Python for AI/ML · all 50 levels

break & continue

Level 17 of 50 · Decisions & loops

Level 17 of 50

break & continue

explained with gol gappay. Watch the reel, then work through it below: run the code, take the quiz, keep the cheat sheet.

📒 Open the cheat sheet
SanaGol gappay! But number 3 is WAY too spicy!
TeacherSo you stop, right there! In Python, that's break!
gol.py
for g in range(1, 6):
    if g == 3:
        break
    print("Ate", g)
Teacherbreak exits the loop instantly. No more gol gappay!
SanaBut what if I just want to SKIP one?
gol.py
for g in range(1, 5):
    if g == 2:
        continue
    print("Ate", g)
TeacherUse continue! It skips that round, and the loop keeps going!

⏸ Pause & predict: what prints?

runs = 0
for b in range(1, 5):
    if b == 3:
        continue
    runs += b
print(runs)

Where this leads

Python is step one. Building AI that ships is the rest.

The diploma takes you from zero to deployed computer vision, LLM and agent projects, with engineers who build them for a living. Already code? The bootcamp does it in three months.