Avatar ·

How to make a temporary cycle correctly?

📁 Advanced Python Topics

We need to make a loop that will perform a function for a minute with an interval of 1 sec.

What is the most effective way? I could not come up with anything better than this:

   from  time  import  sleep. seconds_left =  60    while  seconds_left & gt;  0 :  do_something ()  seconds_left -=  1   sleep (