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

for & range()

Level 16 of 50 · Decisions & loops

Level 16 of 50

for & range()

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

📒 Open the cheat sheet
SanaSir said: write 'I will not talk' 100 times!
Teacher100 times? Python does it in 2 lines! Meet the for loop!
lines.py
for i in range(3):
    print("Line", i)
Teacherrange(3) gives 3 numbers. The loop runs once for each!
SanaWait, why does it start at 0?
lines.py
for i in range(1, 4):
    print("Line", i)
Teacherrange starts at 0 and stops BEFORE the end! Want 1 to 3? Write range(1, 4)!

⏸ Pause & predict: what prints?

mangoes = 0

for i in range(1, 4):
    mangoes += i

print(mangoes)

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.