code: def input_flush():
      
      try:
          import sys, termios  # noqa
          termios.tcflush(sys.stdin, termios.TCIFLUSH)
      except ImportError:
          import msvcrt
          while msvcrt.kbhit():
              msvcrt.getch()
docs: Flush the input buffer on posix and windows.