Loops & Pattern Coder
A loop runs the same steps again and again. Pick your actions, set the repeat count, and watch your pattern build automatically.
How Loops Save Work
Both panels do the same thing. A loop is a shortcut for repeating steps.
Without a loop
With a loop
3 lines instead of 6!
Output so far
How Loops Work
What Is a Loop?
A loop tells a computer to repeat a set of steps a certain number of times. Instead of writing the same instruction six times, you write it once and say "repeat 6 times."
Real programs use loops for everything: drawing shapes, playing music beats, showing a countdown, and filling a grid with tiles.
Loop Count
The number at the top of the loop block is the repeat count. It controls how many times the loop runs.
- Repeat 1 time: runs the body once (same as no loop)
- Repeat 4 times: runs the body 4 times in a row
- Repeat 0 times: never runs — produces nothing
Loop Body
The loop body is the set of steps inside the loop. Every time the loop runs, all the steps in the body happen in order.
If the body has 2 actions and the count is 3, the total output is 2 x 3 = 6 tiles. You can predict the length before you run it.
Nested Loops
A nested loop is a loop inside another loop. The outer loop runs the inner loop multiple times. This is how programs fill grids.
- Outer loop = number of rows
- Inner loop = number of columns in each row
- Total tiles = outer count x inner count