While Statement

The while loop executes as long as the condition remains true. In Python, any non-zero integer value is true and zero is false. The condition may also be a string or list value, in which case anything with a non-zero length is true and empty sequences are false. The body of the loop must be indented, and each line within a block must be indented by the same amount

i = 0
while i < 3:
    print(i)    # 0, 1, 2
    i += 1

results matching ""

    No results matching ""