user2712431
user2712431

Reputation: 25

Making a timer in Python

What I want to do, is for example:

Print something like, "Welcome to my program" Then create a timer for x seconds, after x seconds have passed, it does then next thing, like prints something else like, "To start type Hello"

Upvotes: 0

Views: 87

Answers (1)

vroomfondel
vroomfondel

Reputation: 3106

The time library is very useful:

>>> import time
>>> print "hello"
hello
>>> time.sleep(5)
# 5 second pause
>>> print "done"
done

That will pause all execution of the program for 5 seconds, during time.sleep(). If you want to do other things during the pause, it becomes a much more complicated question, and you should probably look into threading

Upvotes: 1

Related Questions