1

Here is the important part of my code

print(''.join(num))
time.sleep(5)
replit.clear()
guess = input('What number did you see? ')

I am doing this in Replit, if it matters. I am trying to create a memory game, where the user sees a number with increasing digits and has to repeat it from memory. I show them the number, then clear the screen after 5 seconds. However, the user can just type the number while they still see it, before the screen clears. That input counts as the input for "guess", and they win. How do I stop this from happening, allowing the user to only input something after it clears the screen?

  • add `sys.stdin.flush()` before your input call would probably do it i think ... maybe – Joran Beasley Oct 20 '22 at 16:17
  • If you mean putting `sys.stdin.flush()` directly before it, I just tried that and it didn't work. – KyleTalksAlot Oct 20 '22 at 17:15
  • 1
    Check out the answer here: https://stackoverflow.com/a/2521054/8627756 . For some reason, this is surprisingly annoying in Python as opposed to most other languages I have worked with. – Alec Petersen Oct 21 '22 at 00:10
  • @AlecPetersen that answer seems to be for windows, and I am using this on two computers, a Chromebook and a windows computer, and I think, although I'm not sure, that Replit uses a different system than windows. – KyleTalksAlot Oct 21 '22 at 18:16
  • @KyleTalksAlot Have you gotten it to work for either system? – Alec Petersen Oct 21 '22 at 18:43

0 Answers0