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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758199137, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/built-in-functions/any(80): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78