+ 4
what is a function time ??and how do work???
I want put time in my code and after this time print example hello please help me!
3 Answers
+ 7
To add delay sleep() is used.
sleep() function is available in time library,
So, first of all import the time library to your code by using
>>>import time
Then use the sleep() function from that library by
>>>time.sleep(5)
#sleep function takes seconds as a parameter, here it will delay the output for 5 seconds.
Then you can put your actual code which is
>>>print("Hello World")
P.S. this will not work on Sololearn playground.
+ 1
Look up the time module in the official python documentation
Raj understood what you are looking for, time.sleep, but time is a very useful module, you should get familiar with the datetime module eventually too
+ 1
Note: Sleeping a few seconds in total does actually happen--it's just not interactive :)