How to Remove an Item in a Set in Python


In this example, we will learn how to remove an item in a set using the remove() method in Python.

Source Code

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

my_set.remove('c')

print(my_set)

Output:

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