# basics loops

Stopping Early with break

break immediately stops a loop completely, no matter how many times it was supposed to run:

for i in range(10):
    if i == 3:
        break
    print(i)

prints:

0
1
2

(it never even gets to print 3.)

Your turn: read a number stop_at. Loop through range(100) and print each number — but break out of the loop right before you would print stop_at.

💡 need a hint?

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