How to create an infinite loop using while true with a delay in Python

1 Answer

0 votes
# Infinite Loop Using while True With a Delay

import time

count = 0

while True: # infinite loop
    print("Tick:", count)

    if count == 3:
        print("Breaking out of loop...")
        break

    count += 1
    time.sleep(1)

print("Done.")



'''
run:

Tick: 0
Tick: 1
Tick: 2
Tick: 3
Breaking out of loop...
Done.

'''

 



answered Apr 11 by avibootz
...