Python while Keyword
The Python while keyword is used to create a while loop. The While loop allows a set of statements to be executed repeatedly as long as a specified condition is true.
Syntax
while condition: statements
Flow Diagram:
In below mentioned example, program uses while loop to sum all integers from 1 to 5.
sum = 0 i = 1 while (i < 6): sum = sum + i i = i+1 print(sum)
The output of the above code will be:
15
❮ Python Keywords