I’m working on a Python program that takes user input. I want the program to ask for input and if the user doesn’t enter anything and a condition is met (if it is a certain time), I want the program to stop asking
Whenever you ask for input, the whole program just stops and waits. Is there any way to ask for input while still checking other parts of the program? For example,
from datetime import datetime
now = datetime.now()
formatted_time = now.strftime('%H:%M:%S')
time_list = formatted_time.split(":")
hour = int(time_list[0])
name = input("Your name: ")
if hour > 12:
print("Too late")
It never gets to the if hour > 12
because it’s still waiting for input. Is there any way to not have this on Windows? I know there are ways to do a countdown, but I’m not sure how to do this.