I am currently working on a timer and pincode script which should determine whether someone is able to stop the timer in time by inserting the correct code so that the person wins the escape room. I created my escape room in real life. The only thing I want to add to my script is a live count down of the time instead of just showing the time left after someone tried a pincode.
import time from datetime import timedelta, datetime def countdown(t): while t: # while t > 0 for clarity mins = t // 60 secs = t % 60 timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") # overwrite previous line time.sleep(1) t -= 1 print('Blast Off!!!') t = input("Enter the time in seconds: ") countdown(int(t)) def pomodoro(): print("The Escape Room starts now. Find the 4 digits of the pincode. Write the digits in order from lowest to highest. You only have 3 tries") timer_start = datetime.now() secret_code = "3389" allotted_time = timedelta(seconds=6*60) error = 0 while True: print("Enter the 4 digit pincode here:") code = input() now = datetime.now() time_taken = now - timer_start if time_taken > allotted_time: print("You took too much time! You lose!") time.sleep(60) return if code == secret_code: print("You managed to stop the mutation and escaped! You won!") time.sleep(60) return print("That's not the right code!") error += 1 if error == 3: print("You took too many tries! You lose!") time.sleep(60) return print(f"You only have {allotted_time - time_taken} time left!") pomodoro()
buran write Feb-16-2021, 06:04 PM:
my understanding is you have a question, so I deleted the other thread - in Code Share section of the forum.
please, don't start new threads unnecessarily
my understanding is you have a question, so I deleted the other thread - in Code Share section of the forum.
please, don't start new threads unnecessarily