py::builtins::list::count

std::size_t count(const_reference value) const;

Returns the count of elements with given value.

Parameters

value: The value of look for.

Return value

The count of elements with given value.

Complexity

Linear in the size of the list.

Example

#include <pypp/builtins/list.hpp>
#include <pypp/builtins/print.hpp>

int main()
{
    py::print(py::list<int>({0, 2, 1, 4, 0, 3, 0}).count(0));
}

Output:

3