Lesson goal: The while-loop and typing words

Previous: Introduction | Home | Next: Average some numbers

As mentioned, while-loops can make a chunk of program code run over and over until the condition of the while-loop becomes false. Here's an example that asks you to type a word. Suppose we want it to stop asking us to type words if we type the word "done" (without the quotes).

The code won't quite work. What condition you put in the while ... do line that is true if word$\ne$"done" and false if word is equal to done?

Now you try. Put a condition in the while ... do line to stop the while loop when variable word is equal to "done".

Type your code here:

See your results here: