Python Function Reference

time.sleep

Pause the program for the given number of seconds.

Python 3.13
time.sleep(secs)

Parameters

secsint | float
The length of the pause in seconds; a float such as 0.5 works too.

Return value

Nothing (None).

Examples

A one-second pause

Python 3.13
import time

print('Start')
time.sleep(1)
print('One second later')
Start
One second later

Countdown

Python 3.13
import time

for second in range(3, 0, -1):
    print(second)
    time.sleep(0.5)
print('Go!')
3
2
1
Go!

Details

During the pause, the current thread does nothing. In asynchronous code, use await asyncio.sleep(...) instead, otherwise all tasks stop. In the sandbox on this page, the output appears all at once after the program finishes, so the pauses between lines are not visible.

See also

Where to learn