import threading def say_hello(): print("Hello, world!") timer = threading.Timer(5.0, say_hello) timer.start()
import threading def print_message(): print("Message printed!") timer = threading.Timer(2.0, print_message) timer.start()This code will create a Timer object that will call the `print_message()` function every 2 seconds. Package Library: Threading