Python program to remove first occurrence of a given element in the list: Given a list of the elements and we have to remove first occurrence of a given element.
list.remove()
This method removes first occurrence given element from the list.
Syntax:
list.remove(element)
Here,
- list is the name of the list, from where we have to remove the element.
- element an element/object to be removed from the list.
Example:
Input :
list [10, 20, 30, 40, 30]
function call to remove 30 from the list:
list.remove(30)
Output:
List elements after removing 30
list [10, 20, 40, 30]
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer