Search notes:

any

any(iterable) evaluates to True if at least one element of iterable is True, and to False otherwise.
print(any([]))
#
#  False

print(any([False]))
#
#  False

print(any([False, True]))
#
#  True

print(any([False, False, False, True]))
#
#  True

Github repository about-python, path: /builtin-functions/any/simple.py
a = ['foo', 'bar', 'baz']
b = ['one', 'two', 'three', 'four']

if any(word in ['hello', 'bar', 'world'] for word in a):
   print("yes")
else:
   print("no")
#
#  Yes


if any(word in ['hello', 'bar', 'world'] for word in b):
   print("yes")
else:
   print("no")
#
#  No
Github repository about-python, path: /builtin-functions/any/more-complex.py

See also

all()
Python: Built in functions

Index