How to make a time delay in Python

Problem description

How to make a time delay in Python, means how to pause execution of a program for a specified amount of time.

Problem solution

In Python's built-in module, there is a sleep() function which allows us to make a time delay during program execution for a provided number of seconds.

Example:

import time 

print("Count to 10.")
time.sleep(10)
print("It's been 10 seconds!")

We collect traffic information to improve the site.

Anonymous analytics only. No ads, no cross-site tracking.

Learn more