.. index:: py::builtins::list::remove .. _doxycast_pypp_classpy_1_1builtins_1_1list_1af71e78f945299cdfd980035e9a1642b1: .. _py-builtins-list-remove: *py::builtins::list::*\ remove ============================== .. code-block:: cpp void remove(const_reference value); Removes the given element. .. note:: This function removes the element at the index returned by ``this->index(value)``. .. tip:: Equivalent to: (with a difference that it doesn't return) .. code-block:: cpp this->pop(this->index(value)); Parameters ---------- ``value``: The element to remove. Complexity ---------- Complexity of :ref:`py-builtins-list-index` plus complexity of :ref:`py-builtins-list-pop`. Example ------- .. code-block:: cpp #include #include int main() { py::list list = {0, 1, 3, 0}; py::print(list); list.remove(1); list.remove(list[-1]); // Reference to element py::print(list); } **Output**: .. code-block:: text {0, 1, 3, 0} {0, 3}