If you wait out the 4 seconds it says "You ran out of time" which is good. But then, to keep the loop going, you will have to press the enter
key to continue.
I want so that when it prints "You ran out of time" underneath instead of just typing, that it displays an input statement like "Type 'attack' to keep going" and the loop would continue from where it was.
from threading import Timer
import time
monsterhp = int(800)
y = 150
while monsterhp > 0:
timeout = 4
t = Timer(timeout, print, ['You ran out of time.'])
t.start()
print(" ")
prompt = "You have %d seconds Type 'attack' to hit the monster\nType here: " % timeout
answer = input(prompt)
t.cancel()
if answer == "attack":
print("You strike the monster")
time.sleep(1)
monsterhp = monsterhp - y
print("War Lord Health:", monsterhp)