Skip to content
Sign upLog in

How do i add a timer to this?

Profile icon
TejasvMaheshwar

Please try to explain in very simple language ....as am a newbie to both coding and python

You are viewing a single comment. View All
Profile icon
Leroy01010

you need to import time, then set the time that it started at, and then minus that from the time that it ended (see code below)

import time

timeStart = time.time()
choice = input("Enter choice:\n")
timeEnd= time.time()
timeTaken = timeEnd - timeStart

print("That took: " + str(timeTaken) + "seconds")