[trouble #1] stdin.readline() error

kamchur·2022년 7월 22일
0

😁START

I use code input to sys.stdin.readline()
and optical list check in input data

but don't founding and return False

python REPL(Read, Eval, Print, Loop) use to check

0 >>> arr = ['MON', 'TUE', 'WED']
1 >>> b = sys.stdin.readline()
2 MON
3 >>> type(b)
4 <class 'str'>
5 >>> b in arr
6 False
7 >>> b
8 'MON\n'

8 line result MON\n
find cause which don't found data in list
because readline input data and press enter key create empty place to right

solve
write rstrip() method to right of readline()

0 >>> b = sys.stdin.readline().rstrip()
1 MON
2 >>> b
3 'MON'
4 >>> b in arr
5 True
strip([chars])		# remove left, right empty place(gap):whitespace
rstrip([chars])		# remove right empty place(gap):whitespace
lstrip([chars])		# remove left empty place(gap):whitespace

😂END

2022.07.22. first commit
2022.07.22. empty place(gap) → whitespace
profile
chase free

0개의 댓글