1s = {0, 1, 2}
2s.discard(0)
3print(s)
4{1, 2}
5
6# discard() does not throw an exception if element not found
7s.discard(0)
8
9# remove() will throw
10s.remove(0)
11Traceback (most recent call last):
12 File "<stdin>", line 1, in <module>
13KeyError: 0
1# it doesn't raise error if element doesn't exits in set
2
3thisset = {1, 2,3}
4
5thisset.discard(3)
6
7print(thisset)
1>>> s = set([1])
2>>> print s.pop()
31
4>>> print s
5set([])
6>>> print s.pop()
7KeyError: pop from an empty set
8