I'm a total beginner so please excuse my ignorance.
What i want to do is basically get an input from the user, which is either a number from 1 to 9 or a space. I've come up with some code from looking around this website that I believe should work but doesn't. When I try to run it, it just does nothing, no error message or anything.
import msvcrt
numInput = 0
while numInput == 0 :
if msvcrt.kbhit():
if msvcrt.getch() == "1":
numInput = "1"
elif (msvcrt.getch() == "2"):
numInput = "2"
elif (msvcrt.getch() == "3"):
numInput = "3"
elif (msvcrt.getch() == "4"):
numInput = "4"
elif (msvcrt.getch() == "5"):
numInput = "5"
elif (msvcrt.getch() == "6"):
numInput = "6"
elif (msvcrt.getch() == "7"):
numInput = "7"
elif (msvcrt.getch() == "8"):
numInput = "8"
elif (msvcrt.getch() == "9"):
numInput = "9"
elif (msvcrt.getch() == " "):
numInput = " "