Turtle Academy just had a system upgrade if you experience any issues. Please try to hard refresh using CTRL + F5.

If the issues continue please contact us.

23. The while loop

In this lesson we will learn the while loop, What we want to tell the turtle to keep on doing some commands till the condition fulfill. We will learn the syntax and use some samples
Let's start by clearing the screen.
The do.while command consist of 3 parts do.while[ COMMANDS ]condition the command will be executed till the condition fullfill. lets try to print the numbers from 1-10
write the following command make "x 1 do.while [ print :x make "x :x + 1 ] :x < 10
In games we can you the while loop to repeat some actions till the user want to stop
do.while [ make "x ( readword [Please enter a number] ) ] :x < 10
We can make some actions and ask the user if he would like to quit or continue
Write the following commands do.while [ print "yoyo make "answer ( readword [Would you like to stop printing yoyo? yes/no] ) ] notequalp :answer "yes
Now lets play a game :). the computer will choose a number between 1-100 and you should guess the number, if the number a wrong you will get a message saying the number is too big/small
Create the game .. the solution is only optional
TurtleAcademy learn programming for freeYour browser is not supporting canvasWe recomand you to use Chrome or Firefox browsers