Python Set Methods

Python has a set of built-in methods that you can use on sets.

Learn more about set in Python Set Tutorial.

Python Set Methods
MethodDescription
union()Return a new set containing the union of two or more sets
update()Modify this set with the union of this set and other sets
intersection()Returns a new set which is the intersection of two or more sets
intersection_update()Removes the items from this set that are not present in other sets
difference()Returns a new set containing the difference between two or more sets
difference_update()Removes the items from this set that are also included in another set
symmetric_difference()Returns a new set with the symmetric differences of two or more sets
symmetric_difference_update()Modify this set with the symmetric difference of this set and other set
isdisjoint()Determines whether or not two sets have any elements in common
issubset()Determines whether one set is a subset of the other
issuperset()Determines whether one set is a superset of the other