First page Back Continue Last page Overview Graphics

Removing Values

It's possible to remove elements with the method remove() without knowing the corresponding indices.

s.remove(x)

This call removes the first occurence of the value x from the list s.

If x is not contained in the list, the following exeption is thrown:

„ValueError: list.remove(x): x not in list“

>>> colors=["red","green","blue","green","yellow"]

>>> colors.remove("green")

>>> colors

['red', 'blue', 'green', 'yellow']