0

Possible Duplicate:
Python read a single character from the user

I would like to create a line of code that accepts only a single character as it's input. For example...

var = my_input("Type a letter: ")

print var

on running, the moment you pressed a character-producing key, that character would be printed. How would I, then, create the function my_input?

Community
  • 1
  • 1
JShoe
  • 3,186
  • 9
  • 38
  • 61
  • I remember seeing something here, but it was different in linux and windows. – f p Jan 28 '13 at 14:05
  • This thread deals with your exact question: http://stackoverflow.com/questions/510357/python-read-a-single-character-from-the-user – Aonghus McGovern Jan 28 '13 at 14:05
  • Thanks! For some reason, it didn't come up as a duplicate as I was making it, and I did make sure to check. The third answer worked perfectly. – JShoe Jan 28 '13 at 14:13

0 Answers0