언어/파이썬
in 연산자
AlgoPoolJa
2020. 12. 29. 20:11
list에서 in 연산자를 사용하면 값이 있으면 true 없으면 false 가 나온다.
string에서는 한글자씩 비교하면서 일치하는 값이 있으면 true 없으면 false 가 나온다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = "Hello are you there ?" | |
if "ar" in a : | |
print("True") | |
else : | |
print("NOPE") | |
#답 TRUE |
dict에서는 해당하는 key값이 있으면 true 없으면 false 가 나온다. value 와는 아무런 관련이 없다는게 함정이다.