How to Remove Last Item By Using Pop() Method in Python


In this example, we will learn how to remove the last item by using the pop() method in Python.

Source Code

my_set = {'a', 'b', 1, 'c'}

p = my_set.pop()
print(p)

print(my_set)

Output:

{'c', 'a', 1}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments