Looping is about how you can repeat a block of statements until some condition is met. With a while loop, the mechanism for repeating a set of statements allows execution to continue for as long as a specified logical expression evaluates to true.
Let’s try the following sample code:
while x < 10:
x += 1
The while loop check the value condition of x so that it stop to loop if x is greater than 10. Otherwise, it continue to execute the inner block of statements where it will print the value of x and increase the value of x by 1 every time it execute the block of statement.