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)

Sample Output:

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

Python Code Editor:

Improve this sample solution and post your code through Disqus