Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do you wait in python?

+3 votes
asked Sep 1, 2020 by Jacob King (150 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.

2 Answers

0 votes
answered Sep 6, 2020 by LiOS (6,420 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())
commented Mar 21, 2023 by Evan Jones (120 points)
time is not idenafied
+1 vote
answered Jul 17, 2022 by Brendan (160 points)

In python do this:

import time
time.sleep(amount of seconds)
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.