Skip to main content

REPEAT/FOR

REPEAT/FOR allows you to repeat a given block of code <int> times. Also supports an optional parameter for a new variable that keeps count of the current iteration, which is zero based.

Syntax

REPEAT <OPTIONAL: count declaration>,<int>
<codeBlock>

DucklingScript

REPEAT 3
PRINT Hello World

FOR 3
PRINT Goodbye!

Output

Hello World
Hello World
Hello World
Goodbye!
Goodbye!
Goodbye!
warning

Please note that there is a limit to for loops; for loops will eventually error if they run too many times. This can be avoided however by using inner for loops, but that is not recommended.