Home / Python / Reference / List methods

Python list remove() method

Remove the first item equal to a value.

Syntax

list.remove(value)

Raises ValueError if the value is not in the list, so check with in first if it might be missing.

Parameters

valuethe value to remove

Return value

None

Example

Code

colours = ["red", "blue", "red", "green"]
colours.remove("red")
print(colours)
if "pink" in colours:
    colours.remove("pink")
print(colours)

Output

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

Related

Learn it step by step in the free lesson Lists & Tuples, with exercises that check your answers.