Tutorials

Python 3 Tutorial

All Tutorials Learning Tools Login

Python 3 Tutorial · Chapter 15 of 22

Python While Loop

Repeat while a condition stays true.

while checks the condition before each repetition.

Update the counter inside the loop or you may create an infinite loop.

While sample Try it Yourself »
i = 1
while i <= 5:
    print(i)
    i += 1

Classroom Tips

  • Know your start value, stop condition, and update step.