.. index:: py::builtins::range::index .. _doxycast_pypp_classpy_1_1builtins_1_1range_1a6de9d773a22daa3246210e3c9bceaf52: .. _py-builtins-range-index: *py::builtins::range::*\ index ============================== .. code-block:: cpp constexpr std::size_t index(const value_type& value) const; Returns the index of given value. Parameter --------- ``value``: The value to look for. Return value ------------ The index of given element. Exceptions ---------- :ref:`py-builtins-ValueError` if the element can't be found. Complexity ---------- Constant. Example ------- .. code-block:: cpp #include #include int main() { py::range nums(1, 10); py::print(nums.index(5)); } **Output**: .. code-block:: text 4