Opposite of any() function

The Python built-in function any(iterable) can help to quickly check if any bool(element) is True in a iterable type.

    >>> l = [None, False, 0]
    >>> any(l)
    False
    >>> l = [None, 1, 0]
    >>> any(l)
    True

But is there an elegant way or function in Python that could achieve the opposite effect of any(iterable)? That is, if any bool(element) is False then return True, like the following example:

    >>> l = [True, False, True]
    >>> any_false(l)
    >>> True

There is also the all function which does the opposite of what you want, it returns True if all are True and False if any are False. Therefore you can just do:

    not all(l)

From: stackoverflow.com/q/38869155

Back to homepage or read more recommendations: