List Methods

list.remove()

Deletes only the first matching element, selected by identity or equality rather than by position. If the value is absent, raises ValueError. Use pop() when you need the removed object or know its position. Matching may invoke user-defined equality methods, which can fail or have side effects. Removing near the beginning of a CPython list generally shifts the following references.

Formal Syntax & Structure

python syntaxpython
items.remove(value, /)

Parameters & Attributes

NameTypeDescription
valueobjectObject to add or search for.

Return Value

None

The original list changes; no new list is returned.

Working Example

Example Snippetpython
queue = ["draft", "review", "draft"]result = queue.remove("draft")print(queue)print(result)
Python Reference