Python While Loop

Learn how to use while loops in Python.

Python While Loop

The while loop executes as long as the condition remains true.

Basic While Loop

i = 1

while i <= 5:
    print(i)
    i += 1
	

Infinite Loop

If condition never becomes false, loop runs forever.

While Loop with Break

i = 1

while i <= 10:

    if i == 5:
        break

    print(i)
    i += 1
	

Watch Python While Loop Tutorial

Learn Python while loop with simple examples and explanations.