any(iterable) 1

any(iterable)

def any(iterable):
    for element in iterable:
        if element:
            return True
    return False

Here is what the above code is Doing:
1. The any() function takes an iterable (list, string, dictionary etc.) as an argument.
2. The function iterates over each element in the iterable and returns True if any of the element is True.
3. If not, then it returns False.

Similar Posts