Usage of the while Loop
Learn how to use the while loop in a Python program.
We'll cover the following...
The while
loop can be used in three situations:
- Repeating a set of statements until a condition remains
True
. - Repeating a set of statements a finite number of times.
- Iterating through a string, list, and tuple.
First usage of the while
loop
When we use the while
loop to repeat a set of statements until a condition remains True
, it means that we don’t know beforehand how many times the statements need to be executed.
Access this course and 1400+ top-rated courses and projects.