Search notes:

all

all(iterable) evaluates to True if all elements of iterable are True, and to False otherwise.
print( all( [] ))
#
#  True

print( all( [False] ))
#
#  False

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

print( all( [True, True] ))
#
#  True
Github repository about-python, path: /builtin-functions/all/simple.py
a = ['foo', 'bar', 'baz']


if all(word in ['foo', 'bar'] for word in a):
   print("yes")
else:
   print("no")
#
#  no



if all(word in ['foo', 'bar', 'baz'] for word in a):
   print("yes")
else:
   print("no")
#
#  yes



if all(word in ['foo', 'bar', 'baz', 'loch-ness'] for word in a):
   print("yes")
else:
   print("no")
#  
#  yes
Github repository about-python, path: /builtin-functions/all/more-complex.py

See also

any()
Python: Built in functions

Index