Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. Looping in python
  5. While loops in python

While loops in python

While loops are also known as indefinite or conditional loops. The while keep iterating until certain conditions are met. There is no guarantee ahead of time regarding how many times the loop will iterate.

A while loop is a condition loop that will repeat the instructions within itself as long as a condition remains true.

syntax:-

while conditional statement:
    loop body

e.g.,

c = 0
while (c < 3):	 
	c = c + 1
	print("Hello, world!!") 
output- 
Hello, world!!
Hello, world!!
Hello, world!!

This is about while loop in python.

Was this article helpful to you? Yes No

How can we help?