Skip to content
Lesson 1 of 9 Free Preview
Duration: 15 min

Why Loops?

Learn it

Sometimes we need to do the same thing many times. Instead of copying the same blocks again and again, we use a loop. A loop repeats the blocks inside it.

In Scratch, repeat (10) runs the blocks inside it 10 times. Loops make code shorter and easier to change.

🧰 Tool: free Scratch online editor (no account needed to try; a parent can create one to save projects) or the free ScratchJr app for tablets.

Code examples

Without a loop

when green flag clicked
move (10) steps
move (10) steps
move (10) steps
move (10) steps
With a loop

when green flag clicked
repeat (4)
    move (10) steps
end

Same result with fewer blocks. To go further, just change 4 to 20.

Project: Clap loop

  1. Stand up. Clap 3 times, then jump. Do that 4 times. That’s a loop!
  2. In Scratch, make the cat say ‘Hop!’ and move 20 steps, 5 times, using one repeat block.
  3. Change the number to 10. What happens?

Challenge: Write down another loop from real life (like climbing stairs).

Enjoying this lesson?

Enroll in the full course to access all lessons, track your progress, and earn a certificate.

Enroll in Full Course