in Operator
>>> x = [1, 3, 6, 193]>>> 6 in xTrue>>> 7 in xFalse>>> y = { 'Jim' : 'gray', 'Zoe' : 'blond', 'David' : 'brown' }>>> 'Jim' in yTrue>>> 'Fred' in yFalse>>> 'gray' in yFalse
any Opeator
any is a boolean function that returns True if any element of the given iterable evaluates to True. This can seem a little silly until you remember your list comprehensions! Combining these any and in can produce powerful, clear syntax for many situations:
>>> my_big_list = [10, 23, 875]>>> my_small_list = [1, 2, 8]>>> any([x < 3 for x in my_big_list])False>>> any([x < 3 for x in my_small_list])True
