14CREATING CONDITIONAL WHILE LOOPS

image

In Chapter 13, we showed you how to use the For loop to repeat code a certain number of times. For loops are ideal to use when you know exactly how many times you want to repeat code. While is another Small Basic keyword that lets you create loops. It’s useful when you don’t know how many times you want to repeat a loop in advance, because While loops keep running code as long as a condition is true.

A While loop condition is similar to how your parents keep telling you to clean your room until it’s spotless or how you keep eating Thanksgiving turkey until you’re stuffed! When the loop’s condition becomes false, ...

Get Learn to Program with Small Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.