w3resource logo


Python Exercises

Python Exercise: Remove items from Python set

Python sets: Exercise-4 with Solution

Write a Python program to remove item(s) from set.

Sample Solution :-

Python Code :

num_set = set([0, 1, 3, 4, 5])
num_set.pop()
print(num_set)
num_set.pop()
print(num_set)

Output :

{1, 3, 4, 5}
{3, 4, 5}

Python Code Editor:


num_set = set([0, 1, 3, 4, 5])
num_set.pop()
print(num_set)
num_set.pop()
print(num_set)

Improve this sample solution and post your code through Disqus.



Join our Question Answer community to learn and share your programming knowledge.