I'm working on a beginner Python project that involves creating a login system with a timeout feature after too many failed attempts. My setup consists of a while loop to handle the login process and a counter tracking the number of attempts. To implement the timeout, I'm using `os.system("sleep")` since I'm restricted from using the time module. However, during this sleep period, the user can still enter input, which gets recorded once the timeout is over. I'm in a tough spot because I'm limited to only using the `os` and `datetime` modules, and I'm unable to utilize any data entities like classes or dictionaries. Is there a way to effectively manage this input issue with these constraints? Would using escape characters to manipulate the cursor after sleeping help?
1 Answer
Given your limits, you might want to consider whether actually blocking the input is necessary. If you can't interact with keyboard events directly, you could handle the input validation post-attempt. Simply accept the input and check the time against your timeout condition. If the timeout hasn't elapsed, you could inform the user that their input isn't being processed yet. This way, you avoid needing to disable the keyboard outright.

That makes sense! I assume the plan would be to show an error message only if they try to log in too soon?