Menu Close

How to make a time delay in Python?

Sometimes, we want to make a time delay in Python.

In this article, we’ll look at how to make a time delay in Python.

How to make a time delay in Python?

To make a time delay in Python, we can use the sleep function from the time module.

For instance, we write:

from time import sleep
print('foo')
sleep(0.1) 
print('bar')

We call the sleep with the number of seconds to pause the program for.

Conclusion

To make a time delay in Python, we can use the sleep function from the time module.

Posted in Python, Python Answers