Python While Loop
In this post we are going to explain while loop.
When a while loop is encountered, expr is first evaluated in Boolean context. If it is true, the loop body is executed. Then expr is checked again, and if still true, the body is executed again. This continues until expr becomes false, at which point program execution proceeds to the first statement beyond the loop body. For example:
We can also use to while loop to get items from lists.