+ 1

Single character input?

How to make single character input in python?like getch() is there any function in python

13th Apr 2020, 1:32 PM
Lalis
Lalis - avatar
7 odpowiedzi
+ 5
If you just want to work without using Return-key, there seems to be no easy way. But you can check this post, there are several approaches explained: https://stackoverflow.com/questions/510357/JUMP_LINK__&&__python__&&__JUMP_LINK-read-a-single-character-from-the-user
13th Apr 2020, 3:52 PM
Lothar
Lothar - avatar
+ 2
swim....ah...didn't notice you already had the [0] in you original response..forgive me. I just realised what Lilas was looking for....(although a python version) When using getch() from the conio header file..there is no need to hit "enter" after entering a character...but.......my code snippet doesn't do that.....sorry Lilas.
13th Apr 2020, 2:35 PM
rodwynnejones
rodwynnejones - avatar
+ 2
thanks for help But i have to press enter after that.any other solution plz
13th Apr 2020, 3:12 PM
Lalis
Lalis - avatar
+ 1
Wasn't sure if this would work...but... had a go and it does actually work.. myinput = input()[0] print(myinput)
13th Apr 2020, 1:56 PM
rodwynnejones
rodwynnejones - avatar