- remove() is python in-built function which is only work in case of the list data type.
- it remove the selected item from the list
Syntax-
list.remove(item)
- Here list refer the actual list in which we perform this operation
- item refer the element of list which we want to delete from list.
Example
list is [1,2,3]
l.remove(2) will give [1,3]
program-
l=[1,2,3,"one","two","three"]
print("List is",l)
l.remove(3)
print("Now list is ",l)
l.remove("one")
print("Now list is ",l)
l.remove(1)
print("Now list is ",l)
l.remove("two")
print("Now list is ",l)
List is [1, 2, 3, 'one', 'two', 'three']
Now list is [1, 2, 'one', 'two', 'three']
Now list is [1, 2, 'two', 'three']
Now list is [2, 'two', 'three']
Now list is [2, 'three']
l=[1,2,3]
l.remove(4)
print(l)
line 2, in
l.remove(4)
ValueError: list.remove(x): x not in list