Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

while loop

  • while
import random

total = 0
while total <= 100:
    print(total)
    total += random.randrange(20)

print("done")
0
10
22
29
45
54
66
71
77
82
93
done