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

Nested loops

Level 18 of 50 · Decisions & loops

Level 18 of 50

Nested loops

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

📒 Open the cheat sheet
Sana2 overs, balls in each. How do I count every single ball?
TeacherA loop inside a loop! Overs outside, balls inside. Nested loops!
overs.py
for over in range(2):
    for ball in range(1, 4):
        print(ball, end="")
    print()
TeacherFor every over, the inner loop bowls all its balls. 3 per over, here!
SanaWait, why does the inner one restart at 1?
TeacherEach new over starts the inner loop fresh! The empty print() starts a new line.

⏸ Pause & predict: what prints?

plates = 0
for table in range(2):
    for guest in range(3):
        plates += 1
print(plates)

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.