In my program, I have a timer function, it uses a while loop. I want it to return the time past from its start while looping, without stopping the function.
def timer():
time_ = 0
while True:
time.sleep(1)
time_ += 1
return time_
But return breaks the loop. I need something like return to start another function if the time is x :
if timer() < 20:
# do something
else:
# do something else