Future careers in the AI era: what to prepare now

Coding Education

Bayu Nugraha
Children's Coding Specialist

A loop (perulangan) is a programming instruction that tells the computer to repeat a single command or block of code automatically, many times over, without having to write the same command again and again. Loops make programs shorter, cleaner, and much faster to build.
Table of Contents
Two kinds of loop are most common. A for loop is used when the number of repetitions is known in advance, such as "repeat exactly 10 times." A while loop is used when the repetition should continue as long as a condition stays true, such as "keep running while the player's score is under 100." Both stop the moment their task is finished.
In Scratch, a child can see how a loop works through the "repeat 10" block: one small block replaces ten separate commands. Imagine drawing a square. Without a loop, a child has to write "move, then turn" four separate times. With a repeat 4 block, one command is enough, and the character on screen draws all four sides on its own. In a large program, a single loop can save hundreds of lines of code.
To write a loop, you wrap the commands you want to repeat inside a loop block and tell it how many times to run. In Scratch a child drags a repeat 4 block and drops the "move" and "turn" blocks inside it, and the sprite draws a square on its own. In Python the same idea looks like for i in range(4): with the repeated line indented underneath. A while loop runs a little differently: while score < 100: keeps going until the score reaches 100. The pattern is the same in every language, so once a child gets it in Scratch, moving to Python feels familiar.
Loops are one of the first concepts taught in coding because they train children to think efficiently: to spot a repeating pattern and simplify it. This pattern-spotting skill is useful not only at the computer, but also in math and everyday logic. In the Algonova coding course, children learn loops through Scratch projects they can run and play with right away.
Try a free class and watch your child build their first program using loops.
A `for` loop is used when the number of repetitions is known, such as ten times. A `while` loop runs as long as a condition stays true and stops once that condition is no longer met.
Children around age 7 can grasp loops through visual blocks like Scratch. They see one "repeat" block replace many commands, so the idea is easy to understand without typing any code.
An infinite loop is a repetition that never stops because its stopping condition is never reached. It is a common beginner mistake, and learning to avoid it is an important part of coding.
Loops are in almost every app: loading a list of messages, animating a game, or processing data. Whenever a computer does a repetitive task, there is likely a loop behind it.