can we remove a entry from the sets.
what are the commands to use for it?
like, my set conatins (6,5) , (6,7), (7,9)...I need to remove the second entry...what shud I do??
can we remove a entry from the sets.
what are the commands to use for it?
like, my set conatins (6,5) , (6,7), (7,9)...I need to remove the second entry...what shud I do??
my_set.remove((6, 7))
The remove()
method can be used to remove items from a set.
If you've got a list of those tuples you can clear it out like this:
l = [(1,2),(3,4),(5,6)]
[(1, 2), (3, 4), (5, 6)]
l.remove((3,4))
[(1, 2), (5, 6)]
You can use remove()
:
>>> s = set([1, 2, 3])
>>> s.remove(2)
>>> s
set([1, 3])