Watch the VIDEO Tutorial

Looping Statements in Python

Looping statements in python are used to execute a block of statements or code repeatedly for several times as specified by the user.

Python provides us with 2 types of loops as stated below:

While loop

For loop

#1) While loop:

While loop in python is used to execute multiple statement or codes repeatedly until the given condition is true.

We use while loop when we don’t know the number of times to iterate.

Syntax:

while (expression): block of statements Increment or decrement operator

In while loop, we check the expression, if the expression becomes true, only then the block of statements present inside the while loop will be executed. For every iteration, it will check the condition and execute the block of statements until the condition becomes false.