Home >>Python Keywords >Python while Keyword

Python while Keyword

Python while Keyword

Python while keyword will continue until the statement is false and this keyword is used to create a while loop.

Here is an example of Python while Keyword:

z = 0
while z < 9:
  print(z)
  z = z + 2

Output:
0
2
4
6
8
Example 2:

y = 0
while y < 10:
  print(y)
  y = y + 1

Output:
0
1
2
3
4
5
6
7
8
9

No Sidebar ads