while Statement

Python’s while is the first looping statement. In fact, it is a conditional looping statement. In comparison with an if statement where a true expression will result in a single execution of the if clause suite, the suite in a while clause will be executed continuously in a loop until that condition is no longer satisfied.

General Syntax

while expression:
    suite_to_repeat

The suite_to_repeat clause of the while loop will be executed continuously in a loop until expression evaluates to Boolean false. This type of looping mechanism is often used in a counting situation, such as the example in the next subsection.

>>> count = 0
>>> while (count <9):
	print "the index is :",count
	count = count + 1

	
the index is : 0
the index is : 1
the index is : 2
the index is : 3
the index is : 4
the index is : 5
the index is : 6
the index is : 7
the index is : 8