input character in python like getchar in c

Solutions on MaxInterview for input character in python like getchar in c by the best coders in the world

showing results for - "input character in python like getchar in c"
Catalina
27 Nov 2016
1import sys
2str = ""
3while True:
4    c = sys.stdin.read(1) # reads one byte at a time, similar to getchar()
5    if c == ' ':
6        break
7    str += c
8print(str)
9
similar questions