Python
(파이썬) 내장함수 any()
코딩ABC
2023. 12. 20. 14:13
반응형
파이썬의 내장함수(Built-in Function)인 any() 함수에 대해 알아봅니다.
any(iterable)
Return True if any element of the iterable is true. If the iterable is empty, return False. Equivalent to:
iterable의 요소 중 하나라도 true이면 True를 반환합니다. iterable이 비어 있으면 False를 반환합니다. 다음과 동일:
def any(iterable): for element in iterable: if element: return True return False |
iterable: 반복 가능한 데이터
참고: 내장함수 all()
(예)
>>> any([False, 0])
False
>>> any([0, 10, 20])
True
>>> any([])
False
반응형