Hello friends, lets learn about flow control Statements
In this post, I'll explain about while loop
The syntax of while loop:
counter_var
while condition:
# Code to execute
Increment/Decrement the counter_var
Remember, in Python indentation plays a very important role.
We do not use curly brackets for defining the while loop instead indentation is used to define the code within the while loop.
Check out the following code:
In this post, I'll explain about while loop
The syntax of while loop:
counter_var
while condition:
# Code to execute
Increment/Decrement the counter_var
Remember, in Python indentation plays a very important role.
We do not use curly brackets for defining the while loop instead indentation is used to define the code within the while loop.
Check out the following code:
condition = 1
while condition < 10:
print(condition)
condition += 1
# Infinte loop
# Ctrl C to break the loop
while True:
print ("Processing...")
Output |