pop first occurence of element in list python code example
Example 1: python remove element from list
myList.remove(item) # Removes first instance of "item" from myList
myList.pop(i) # Removes and returns item at myList[i]
Example 2: remove first occurrence of element from list python
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]