Dear readers, in today’s tutorial, know what is the use of Time.sleep () method in Python?
The method time.sleep () is used to stop the execution of the program for a certain time. This is an argument i.e., time in seconds. This will stop execution until a given second.
Example for Observe the time delay
import time # write something print("Hi! I am aitechtonic") # delaying the execution for 1 sec time.sleep(1) # printing something print("Completed")
Result
Hi! I am aitechtonic Completed
Example – use of time.sleep() method
import time string = 'Aitechtonic' for char in string: print(char, end=' ') # delay time.sleep(0.3)
Result
A i t e c h t o n i c