Python-Dictionary

What’s the difference between remove(),pop() and del

In remove() function you pass the element in the parameters and it will remove the first occurring element in the list
a = [0, 2, 3, 2]
a.remove(2)
a
[0, 3, 2]

In del function you can specify index for element removal
a = [3, 2, 2, 1]
del a[1]
a
[3, 2, 1]

In pop() is returns the last element if no parameter is passed or you can pass the index value of any element you want to remove
a = [4, 3, 5]
a.pop(1)
3
a
[4, 5]

p = [1,2,3,4,5,6]
p.pop()
6
p
[1,2,3,4,5]

Hi Himanshu, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.