While Loop Statements

The code in the while clause will be executed as long as it’s condition is True.

while statements always consist of:

  • The while keyword
  • A condition
  • A colon
  • Starting on a newline, an indented clause

AKA the while loop.

Example #

while spam < 5;
    print('Hello, world.')
    spam = spam + 1