4

In Jupyter, using python 3, I am trying to run a cell that is supposed to ask for a single character input in a for loop and store the answer in a list. I wanted to avoid the use of input() to avoid having to press enter everytime.

Working in windows, I tried:

import msvcrt

charlist = []

for x in range(10):
    print("Some prompt")
    a = msvcrt.getch()
    charlist.append(a)

but when running the cell, the kernel gets stuck at the first instance of the getch() line without accepting any input. Is there any way to do this in a Jupyter notebook?

msfrn
  • 57
  • 3
  • I think this is what your are looking for. https://stackoverflow.com/questions/510357/python-read-a-single-character-from-the-user – beka gogaladze Dec 26 '19 at 08:32

0 Answers0