Python Loops

In Python loop, the statement is executed sequentially until the condition satisfied. The first statement during a operate is dead first, followed by the second, and so on. Using Loops we can execute a block of code several times.

python while loop control flow

Python have two types of loops

Python While Loop

While loop we will execute a group of statements as long as a condition is true.

count = 1
while i < 6:
  count = count + 1

We use a counter (variable-count) while so that it does not go into an infinite loop.

# While Loop
count = 1
while (count < 10):
  if(count == 5):
     print("Count", count)
     count = count + 1
     print("Else Count", count)
Python While Loop Video Tutorial

Whats Next – Python FOR Loop