Skip to content
Kids
KreerIQ

Loops: repeat without repeating yourself

Loading…

Free lesson

What you will learn

By the end, you can read a repeat loop, count how many moves it makes, and use one to draw a square.

To draw a square, Dev wrote move forward, turn right, move forward, turn right… eight lines, and he still made a typo on line seven. Then he found a block that says the same thing in three lines: repeat 4 times.

Read the explanation

A loop tells the computer to run the same block of lines again and again. "repeat 4 times:" runs everything indented under it four times. Loops keep programs short and stop mistakes: you write the block once, and the computer does the repeating.

  • The number after repeat says how many times the block runs.
  • Total moves = moves inside the block × number of repeats.
  • Only the indented lines are inside the loop.
All tracks