remove() is an inbuilt function in Python programming language that removes a given object from the list. It does not return any value.
obj - object to be removed from the list
The method does not return any value but removes the given object from the list.
Note:It removes the first occurrence of the object from the list.
[2, 1, 1, 4, 5] ['b', 'c', 'd']
It returns ValueError when the passed object is not present in the list
Traceback (most recent call last): File "/home/e35b642d8d5c06d24e9b31c7e7b9a7fa.py", line 8, in list2.remove('e') ValueError: list.remove(x): x not in list
Given a list, remove all the 1’s from the list and print the list.
[2, 3, 4, 4, 5]
- Python | Remove all values from a list present in other list
- Python | Remove last K elements of list
- Python | Remove Duplicates from a List
- Python | Remove None values from list
- Python | Remove given element from the list
- Python | Remove all strings from a list of tuples
- Python | Remove all occurrences in nested list
- Python | Remove square brackets from list
- Python | Ways to remove particular list element
- Python | Remove and print every third from list until it becomes empty
- Python | Ways to remove duplicates from list
- Python | Remove consecutive duplicates from list
- Python | Remove random element from list
- Python | Remove all digits from a list of strings
- Python | Remove repeated sublists from given list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.