You can use sleep() method to sleep a thread for a specified amount of time. This method provides accurate and flexible way to halt a code for any period of time.
Have a look at the below given example for better understanding:
Input:
import time
#printing the time when code execution began
print("code execution began at : ", end ="")
print(time.ctime())
#using sleep to halt the code execution
time.sleep(10)
#printing the time when code execution ended
print("code execution ended at : ", end ="")
print(time.ctime())
Output:
code execution began at : Tue May 28 07:41:48 2019
code execution ended at : Tue May 28 07:41:58 2019