- while
Infinite while loop
examples/loops/while_infinite.py
import random total = 0 while total >= 0: print(total) total += random.randrange(20) print("done")
... 1304774 1304779 1304797 ^C1304803 Traceback (most recent call last): File "while_infinite.py", line 5, in <module> print(total) KeyboardInterrupt
- Don't do this!
- Make sure there is a proper end-condition. (exit-condition)
- Use Ctrl-C to stop it