py::builtins::list::remove

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)

this->pop(this->index(value));

Parameters

value: The element to remove.

Complexity

Complexity of py::builtins::list::index plus complexity of py::builtins::list::pop.

Example

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

int main()
{
    py::list<int> list = {0, 1, 3, 0};

    py::print(list);

    list.remove(1);
    list.remove(list[-1]); // Reference to element

    py::print(list);
}

Output:

{0, 1, 3, 0}
{0, 3}