I've been asked the question:
Define a second function which, when called, will “sleep” for approximately three seconds, and while doing so will display a “z” on the screen about every ½ a second. Do not use the sleep function to accomplish this task as we have not studies.
I do not know how to do this, please help
CodePudding user response:
You could use the time
module:
from time import time
start_time = time()
end_time = start_time 3
next_z = start_time 0.5
while next_z < end_time:
if time() > next_z:
print('z')
next_z = 0.5