+ 3
What is the basic difference between pop and remove? Does pop remove the last element of the set?
2 Answers
+ 1
set={1,2,3,4,5,6,7,8,9,}
remove= It removes the specific element from the set, whic you have specified ...like remove(5)
in this the element #5 will be removed from the above set.
set={1,2,3,4,6,7,8,9,}
pop= It removes a random element from the above remaining items in the set.
0
set.pop[index] remove items by their index.
if you don't put an index it removes last item by default.
unlike set.remove(x) which removes specific item.