While Loop In Python

While Loop

A while statement in Python executes a block of code repeatedly as long as the test/control condition of the loop is true. The control condition of the while loop is executed before any statement in the body of the loop is executed. If the condition is true, the body of the loop is executed. Again the control condition of the loop is tested and the loop continues as long as the condition remains true. When the test outcome of this condition becomes false, the loop is not entered again and the control is transferred to the statement immediately following the body of the loop.

Syntax of while loop:

 

 

Also Check: While loop exercises for CBSE Computer Science Students.