Adds an element to a set, creating a unique collection of hashable objects
Reference
Set Methods
Methods available on Python set objects.
- set.add()
- set.clear()
Removes all elements from a set, leaving it empty
- set.copy()
Creates a shallow copy of a set, returning a new set with the same elements
- set.difference_update()
Removes all elements from this set that are also in another set, modifying the original set in place
- set.difference()
Returns a new set containing elements in the calling set but not in the iterables
- set.discard()
Removes an element from a set if it exists, without raising an error if the element is not found
- set.intersection()
Returns a new set containing only elements that exist in all sets
- set.isdisjoint()
Check if a set has no elements in common with another set
- set.issubset()
Check whether all elements of one set are contained in another set
- set.issuperset()
Check if a set contains all elements of another set
- set.pop()
Removes and returns an arbitrary element from a set, raising KeyError if the set is empty
- set.remove()
Removes an element from a set, raising KeyError if the element is not found
- set.symmetric_difference_update()
Updates a set in-place with elements in either set but not in both
- set.symmetric_difference()
Returns a new set containing elements in either set but not in both
- set.union()
Returns a new set containing all elements from multiple sets
- set.update()
Adds all elements from one or more iterables to a set, modifying it in place