py::builtins::range::count

constexpr std::size_t count(value_type value) const;

Returns the count of values with given value.

Parameters

value: The value to look for.

Return value

The count of values with given value, always either 0 or 1.

Complexity

Constant.

Example

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

int main()
{
    py::print(py::range(10).count(9));
}

Output:

1