6 Antworten
+ 4
Yes, have u tried datetime module?
+ 2
You can use the time.time() function. It returns the time since Jan 1st 1970 in seconds!
So, you can just do this :
import time
b = True #declare boolean so that code can be executed only if it is still True
t1 = time.time()
answer = input("Question")
t2 = time.time()
t = t2 - t1
if t > 15:
print("You have run out of time!")
b = False
if b == True:
#Rest of code
I hope this helped! Happy programming :)
+ 1
TheCoder thanks!
0
Tomáš Konečný i haven't, i will check it out now.
0
kristine you're welcome!