Reputation: 63
I have a basic code with simple condition:
if var1 > 0 :
dosomething
how can I prolong the execution after the condition is true for few seconds? Something like:
if var > 0 ("after 5 seconds"):
dosomething
Upvotes: 0
Views: 45
Reputation: 5714
Try something like this ; sleep(5)
will delay the program for 5 seconds:
import time
x = 10
if x > 0:
# if true
time.sleep(5)
else:
#dosomething
Upvotes: 0
Reputation:
Use time.sleep
at an appropriate place:
from time import sleep
sleep(5) # will block for 5 seconds
Upvotes: 3