The while loop in the game() only runs for 10 sec. I want to reset the time (run the while loop for 10 sec again). when certain conditions are meet. The code below is not even executing the if condition.
import time
gametime = time.time() 10
def game():
print("Seconds since epoch =", gametime)
var = 1
while time.time() < gametime:
print ("hello")
hello = input("reset time: ")
print("test1")
if (hello == var):
print("test")
print(gametime)
reset()
print("time is up")
def reset():
global gametime
gametime = time.time() 10
game()
CodePudding user response:
You need to parse the hello
variable as int
.
This seems to be working:
if (int(hello) == var):
print("test")
print(gametime)
reset()