Skip to content
Sign upLog in
← Back to Community


Profile icon

How do I add time? I mean like for my codeing I want it to wait like 5 sec before it continues.Can yall help me out

Answered by RYANTADIPARTHI [earned 5 cycles]
View Answer
Profile icon
Profile icon

You have to use time.sleep() to do this job:

import time print('Hi') time.sleep(5) # change the number to how many seconds you want print('this is 5 seconds later')

like that.
That should work

Profile icon

There is a sleep function in the time module. The code would be

import time
time.sleep(amount of seconds to sleep)

Profile icon

What you are looking for is time.sleep.

import time print("Hello, ") time.sleep(5) print("World!")

read more

Profile icon

For python, you can import the module time:

import time # importing time print("Hi!") time.sleep(1) # program waits 1 second print("And I'm back after 1 second!")

You can also do this:

from time import sleep # imports sleep from time print("Hi!") sleep(1) # program waits 1 second print("And I'm back after 1 second!")

The only difference is that on the first line we do from time import sleep and when we want to use it, we do sleep(seconds) instead of time.sleep(seconds). It's the same thing.


Profile icon
import time # Waits 5 secs time.sleep(5)