Method Signature
remove(element_in)
Method Overview
- The method remove() of set class removes an element from an existing Python set object.
- The method does not return a new set object. It returns None.
Parameters
element_in : The element that is to be removed from the Python set object.
Exceptions
KeyError - raised if the specified element is not in the Python set object. Note that the elements of a set are all keys and set is an associative container.
Example
# Example Python program that removes an element
# from a Python set
foodPlate = {"Salmon", "Beans", "Bacon", "Broccoli"}
foodPlate.remove("Bacon")
print(foodPlate)Output
{'Beans', 'Salmon', 'Broccoli'}