Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to input one letter at a time in python? [duplicate]

I want to take one letter at a time in python. can we take one letter at a time using "input()" in python3

Example: I want to input only one letter such as a. b, c, .....etc. It should not accept more than one letter word such as ab, as, asa ... etc. is there any such function in python 3?

like image 274
bhargav Avatar asked Sep 16 '25 12:09

bhargav


1 Answers

Use the getch module.

import getch
# ...
char = getch.getch() # User input, but not displayed on the screen
# or
char = getch.getche() # also displayed on the screen
like image 87
blhsing Avatar answered Sep 18 '25 11:09

blhsing