How do you wait in python?

+2 votes
asked Sep 1 by Jacob King (140 points)
I just want to pause the program for 3 seconds. I looked it up and a bunch of websites said to use "time.sleep(secs)". (I typed in 3 in the parenthesis of course) But this does not work when I type it in.

1 Answer

0 votes
answered Sep 6 by LiOS (4,660 points)
In Python, you will need to import a library that contains a sleep (or similar name) function.

The most basic library that contains a sleep function is time but there are lots of others.

The below code sleeps for 3 seconds.

import time

print ("Start : %s" % time.ctime())
time.sleep( 3 )
print ("End : %s" % time.ctime())
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...