Chapters
Python114 chapters

ReferenceList methods

list.remove()

Removes the first item equal to the value.

Signature

items.remove(value)

Parameters

NameMeans
valuewhat to look for

Returns

None. Raises ValueError when there is no match.

Example

Python
names = ["Ada", "Grace", "Ada"]
names.remove("Ada")
print(names)

try:
    names.remove("Alan")
except ValueError:
    print("not in the list")

Output

['Grace', 'Ada']
not in the list

See also