Question
What kind of conditions can a while loop check?
Answer
Any boolean expression can be used to make the condition for a while
loop. In one of the earlier lessons we learned about comparators like <=
and ==
, and boolean operators like and
, or
, and not
.
Anything that results in True
or False
can be used as the condition for a while loop to check. The important thing is to ensure that the condition eventually results in False
at some point, otherwise you get an infinite loop!