DEV Community

Cover image for Creating Delays in Python Programs
Daniel Nogueira
Daniel Nogueira

Posted on • Edited on

Creating Delays in Python Programs

Short breaks can be fun and functional in some programs. Creating a waiting time before displaying a text, for example, can make the process of using that program more real.

For that, let's import the sleep() method from the time module:

from time import sleep
Enter fullscreen mode Exit fullscreen mode

And now just call the sleep() method specifying the time in seconds:

# 3 second delay
sleep(3)

# 1 minute delay
sleep(60)
Enter fullscreen mode Exit fullscreen mode

Example of how delays can make a program more real:

print('Jo')
sleep(1)
print('Ken')
sleep(1)
print('Po')
sleep(1)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more