Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python list remove() method is used to delete the first occurrence of a specified element from the list. If specified element does not exist in the list, the method will raise an exception.

Syntax

list.remove(elem)

Parameters

elem Required. value of the element which need to be removed from the list.

Return Value

None.

Example:

In the below example, list remove() method is used to delete the first occurrence of element called 'MAR' from the list called MyList. When an element called 'DEC' is attemped to delete from MyList which is not present in the list, the method raises an exception.

MyList = ['JAN', 'FEB', 'MAR', 'MAR', 'APR']

MyList.remove('MAR') 
print(MyList)


MyList.remove('DEC') 
print(MyList)

The output of the above code will be:

['JAN', 'FEB', 'MAR', 'APR']

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

❮ Python List Methods