Hi,
Lets look at all the methods one by on:
1) Remove
This method has nothing to do with index, it removes the first matching element present in the list.
Syntax:
list.remove(value)
Input:
a=[2,6,7,2]
a.remove(6)
a
Output:
[2, 7, 2]
2) Delete
This method removes an element from specified index.
Syntax:
del list[index]
Input:
a=[2,6,7]
del a[1]
a
Output:
[2, 7]
3) Pop
This method removes an element at a specified index and returns it.
Syntax:
list.pop[index]
Input:
a= [2,6,7]
a.pop(1)
a
Output:
[2, 7]
Difference:
- Remove() deletes the matching element from the list whereas the del and pop removes the element present at specified index
- Difference between pop and del is that pop returns the deleted value whereas del does not