CHAPTER 6

The Time Loop ⏳

A wizard never writes the same spell 100 times. That's boring! 😴

Instead, we use a Loop. It tells the computer: "Do this part X times". It's like time travel, going back to the start of the line!

🔁 The For Loop

This spell repeats code 5 times.

for i in range(5):
    print("Looping!")
💡 THE SECRET VAR 'i'
i is a variable that counts for you. It starts at 0.
So range(5) counts: 0, 1, 2, 3, 4. (It stops before 5!)

YOUR QUESTS ⚔️

Quest 1: The Echo

Make the computer print "I am coding!" 5 times using a loop.

for i in range(5):
    print("I am coding!")
Waiting for you to run code...

Quest 2: Counting Up

Now let's see the invisible number! Print the variable i inside the loop.
Check if it goes from 0 to 4.

for i in range(5):
    print(i)
Locked 🔒

Quest 3: Super Math

Computers are fast. Print i * 100 inside the loop.
It should show 0, 100, 200, 300, 400!

Locked 🔒

Wizard's Exam 📜

1. range(3) counts which numbers?

⌨️ EDITOR
Waiting for code...