Loops

A loop is a way of executing the same lines of code multiple times without having to literally write them out more than once. A SeaTurtle loop starts with theREPEAT keyword followed by a number of times to repeat. Then the lines of code that should be repeated are written. Finally, the loop's end is indicated with the END keyword. For instance, the following program will use a loop to draw a square:

REPEAT 4
    FORWARD 50
    RIGHT 90
END

As in the preceding example, it is good style to indent the lines of code that make up the "body" of the loop. Loops are powerful programmatic constructs that save you some typing. There's an acronym that's also a mantra in programming: DRY-Don't Repeat Yourself. Loops are a way to not have to repeat yourself. Let the computer do the repeating for you.