Reputation: 21
I was making a discord bot and wanted to make a timer, but without using a loop. The problem with a loop is that it would stop the rest of the circuit until it's done executing the loop. Is there a way to get around this? I did search how to do it, but all of them used while x > 60
which would not work in this case.
Upvotes: 0
Views: 655
Reputation: 467
You need to use threads, and that would look something like this:
import threading
def func():
times = 0
while times < 10:
print(times)
times += 1;
x = threading.Thread(target=func)
x.start()
n = 100
while n < 110:
n += 1
print(n)
Here both while loops run at the same time
Upvotes: 3