# basics loops

while Loops

A while loop repeats as long as a condition stays True. You have to update something inside it, or it'll never stop:

count = 0
while count < 3:
    print(count)
    count += 1

prints:

0
1
2

Your turn: read a number n. Using a while loop (not for this time), print every number from 0 up to (not including) n, one per line.

💡 need a hint?

pyb-loop-while.py🔒 given lines are locked — write your code in between
loading...