Python while loop Function



>>> x = 3
>>> while (x < 10):
... 	print(x)
... 	x += 1  #if not incremental here, it will be infinite loop
...
3
4
5
6
7
8
9

break keyword can jump out of the loop:
>>> x = 3
>>> while (x < 10):
... 	print(x)
... 	x += 1  #if not incremental here, it will be infinite loop
... 	if (x == 8): break
...
3
4
5
6
7

else keyword will handle the result when condition is False:
>>> x = 3
>>> while (x < 10):
>>> 	print(x)
>>> 	x += 1
>>> else:
>>> 	print("x is: ", x)
3
4
5
6
7
8
x is: 10