remove()

The remove() method removes an item from the list by it’s value.

>>> spam = ['cat', 'bat', 'rat', 'elephant']
>>> spam.remove('bat')
>>> spam
['cat', 'rat', 'elephant']
  • If the item doesn’t exist it throws an error.
  • If the item appears multiple times only the first occurrence is removed.

See also #