There is a very hacky way to do this using time.asctime (). You save asctime before entering the while loop and somewhere in the loop itself. Calculate the time difference between the stored time and the current time, and if this difference is 10 seconds, then update the stored time to the current time and print it.
However, this is a very hacky way to do this, as it requires some perverse and boring math.
If your goal is to check the execution time of a particular algorithm, then you better use the timeit module
Hope this helps
inspectorG4dget
source share