Python: sleep command - simply explained
The sleep command in Python is extremely practical. It causes a program to wait a short time before executing further commands. Here we explain how to use the sleep command exactly.
Python: Use sleep command
You can easily add the sleep command to your program code:
- Add the line "from time import sleep" (without quotes) to the beginning of your code so that you can use the sleep function later.
- Now you can add the "sleep (1)" command anywhere in the code.
- In brackets you have to write the time in seconds that the program should wait.
- In this case, the program waits exactly one second.
More tips about Python in our CHIP guides
Tip: On our topic page on the Python programming language you will find further tutorials on programming. There we will show you, for example, how you can convert an integer into a string.