Why does the ‘and’ work in this while loop and ‘or’ doesn’t?

The expression in while specifies when the loop should keep running. and means that both conditions have to be true for the expression to be true. So if either of the conditions is false, the and expression is false, and the loop stops.

If you change it to or, the expression is true if either condition is true. So you’ll keep looping as long as the user doesn’t guess the word, even if they’ve run out of guesses.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top