Answer the question
In order to leave comments, you need to log in
How to stop the execution of the loop after a certain time without interfering with the code that is being executed in the loop?
The loop performs a certain function, and after a while it must finish executing the function, and the loop itself.
Here is the loop itself:
for i in range(100):
new_people_and_actions()
Answer the question
In order to leave comments, you need to log in
Maybe, if we are talking about time, then do this:
import time
stop = time.time() + 10 # сколько секунд будет выполняться функция
while stop > time.time():
new_people_and_actions()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question