Programming Language/Python
[Python] 리스트에 특정 값이 있는지 체크하기
yuseon-Lim
2021. 1. 5. 11:12
리스트에 특정 값이 있는지 체크
list = ['apple', 'banana', 'cherry']
if 'apple' in list:
print("리스트에 'apple'이 있습니다.")
if 'watermelon' not in list:
print("리스트에 'watermelon'이 없습니다.")
결과
리스트에 'apple'이 있습니다.
리스트에 'watermelon'이 없습니다.
반응형