In this example we will show how to remove an item in a set using the discard() method in Python.
Source Code
my_set = {'a', 'b', 1, 'c'}
my_set.discard('c')
print(my_set)
Output:
{1, 'b', 'a'}
In this example we will show how to remove an item in a set using the discard() method in Python.
my_set = {'a', 'b', 1, 'c'}
my_set.discard('c')
print(my_set)
Output:
{1, 'b', 'a'}
In this example we will show how to remove an item in a set using the remove() method in Python.
my_set = {'a', 'b', 1, 'c'}
my_set.remove('c')
print(my_set)
Output:
{1, 'a', 'b'}