#unlike set.remove(), If the target element does not exist, set.discard method does not raise a KeyError, it returns None instead. myset = {1, 3, 4, 5, 7, 8, 9} #remove elements myset.discard(4) myset.discard(8) print(myset)
#unlike set.remove(), If the target element does not exist, set.discard method does not raise a KeyError, it returns None instead. myset = {1, 3, 4, 5, 7, 8, 9} #remove elements myset.discard(4) myset.discard(8) print(myset)