When we want to execute some code many times, we can always copy-paste those commands. But that is not very efficient or readable, so we have commands like "While".

A While command has two parts:

Let's write a program that prints numbers 1 to 5:

You should see numbers 1,2,3...5 printed in the output panel.

Notice the Assign command: x = x + 1. You can use x's previous value (before Assign was executed), when calculating its new value! How cool is that? :)

CodeExploreLearnLog In