While loop in Python
The while loop iterates a block of code continuously until the given condition becomes false.
Syntax :
while(condition) :
your code here
Example :
i = 0
while(i < 10) :
print(i)
i+=1
The Output for the above code will be :
0
1
2
3
4
Note: Always write the increment/decrement statement inside the while loop. If not given, it will become an infinite loop.
In python, i++ or i-- is not supported. Instead we use i+=1 and i-=1.