In this tutorial, we are going to learn about the time.sleep() method.
The method time.sleep() is used to stop the execution of a program for a certain time. It an argument i.e.., time in seconds. It will stop the execution until the given seconds.
Let's see a simple example. Observe the time delay while executing the following code
Example
# importing the time module import time # printing something print("Yeah! I am something") # delaying the execution for 1 sec time.sleep(1) # printing something print("Completed")
Output
If you run the above code, then you will get the similar result as follows.
Yeah! I am something Completed
Run the following program and observe the delays.
Example
# importing the time module import time string = 'Tutorialspoint' for char in string: print(char, end=' ') # delay time.sleep(0.3)
Output
If you run the above code, then you will get the similar result as follows.
T u t o r i a l s p o i n t
Conclusion
If you have any doubts in the tutorial, mention them in the comment section.