Skip to main content

Python While Loop

Body

In this tutorial you will learn:

  • While loop in Python
  • Nested while  loop in Python
  • Break statement in while  loop
  • Continue statement in while loop

While loop in Python

A while loop in Python is just like any in any other programming language. Just like a for loop a while loop also needs initialization, condition and increment. A while loop keeps on running until the condition is true. If we want the loop to run indefinitely then we can pass 1 or true in while loop. Let’s go through the examples we did in for loop using while loop.

Example:

numbers = [67,85,23,45,6,7,8,2,1]

Add new comment