Skip to main content

Python Loop Control Statements

Python Loop  control statements are used to  stop or skip or pass pocess or blocks untl certain conditions met true. In this tutorial we will learn about Python loop control statements. Pyhton has control statements such as break, continue and pass. They are used to control the  loop statements. 

In this tutorial we will learn about Python programming loop control statements.The break statement, continue and ass  statements to control the loops.

Techtuts provides an example along with concepts. You have to workout the example programs for good and well.

Control statements in Python

Python has the following three control statements

  1. break
  2. continue
  3. pass

The break statement:

The break statement in a Python Programming used to stop the loop execution on certain condition met.

Example

>>> count=0
>>> while count < 5:
...     print(count)
...     if count == 3:
...             break
...     count = count+1
...
0
1
2
3
>>>

The continue statement:

The continue statement in a Python Programming used to skip the loop execution on certain condition met.

Example

>>> count = 0
>>> while count < 5:
...     print(count)
...     if count == 3:
...             print("continue")
...     count = count + 1
...
0
1
2
3
continue
4
>>>

The pass statement:

The pass statement in a Python Programming used to like as a placeholder or experimental execution.

Example

>>> pass
>>> n=5
>>> if n > 4:
...     pass  # it is like placeholder
...
>>>