Home >>Python Set Methods
There are more than 15 Python set of built-in methods that can be used on sets.
Method | Description |
---|---|
add() | It is used to add an element to the set. |
clear() | It is used to remove all the elements from the set. |
copy() | It is used to return a copy of the set. |
difference() | It is used to return a set containing the difference between two or more sets. |
difference_update() | It is used to remove the items in this set that are also included in another specified set. |
discard() | It is used to remove the specified item. |
intersection() | It is used to return a set that is the intersection of two other sets. |
intersection_update() | It is used to remove the items in this set that are not present in other specified set. |
isdisjoint() | It is used to return whether two sets have a intersection or not. |
issubset() | It is used to return whether another set contains this set or not. |
issuperset() | It is used to return whether this set contains another set or not. |
pop() | It is used to remove an element from the set. |
remove() | It is used to remove the specified element in the set. |
symmetric_difference() | It is used to return a set with the symmetric differences of two sets. |
symmetric_difference_update() | It is used to insert the symmetric differences from this set and another. |
union() | It is used to return a set containing the union of sets. |
update() | It is used to update the set with the union of this set and others. |
Learn more about Python Sets Python Sets