.. index:: py::builtins::any .. _doxycast_pypp_namespacepy_1_1builtins_1a426b6230c778ecefbd2c01aa26a8464a: .. _py-builtins-any: *py::builtins::*\ any ===================== *Defined at* ```` .. code-block:: cpp template constexpr bool any(const type& iterable); Checks whether any element of an array is ``true``. .. note:: Calling this function is equivalent to the following: .. code-block:: cpp iterable[0] || iterable[1] || iterable[2] || ... Template parameters ------------------- ``type``: The type of iterable object. .. admonition:: Requirements of ``type`` ``type`` must iterable with for loop and elements stored by the iterable object must be ``bool`` or implicitly convertable to ``bool``. Parameters ---------- ``iterable``: An iterable object. Return value ------------ Whether any element of the iterable is ``true``. Complexity ---------- Linear in the size of ``iterable`` at most. Example ------- .. code-block:: cpp #include #include #include int main() { py::list a = {true, false}; py::print(py::any(a)); } **Output**: .. code-block:: text true