2. Sets

2.10. Resumen de métodos

Set Methods

Function Description
add() Adds an element to a set
remove() Removes an element from a set. If the element is not present in the set, raise a KeyError
clear() Removes all elements form a set
copy() Returns a shallow copy of a set
pop() Removes and returns an arbitrary set element. Raise KeyError if the set is empty
update() Updates a set with the union of itself and others
union() Returns the union of sets in a new set
difference() Returns the difference of two or more sets as a new set
difference_update() Removes all elements of another set from this set
discard() Removes an element from set if it is a member. (Do nothing if the element is not in set)
intersection() Returns the intersection of two sets as a new set
intersection_update() Updates the set with the intersection of itself and another
isdisjoint() Returns True if two sets have a null intersection
issubset() Returns True if another set contains this set
issuperset() Returns True if this set contains another set
symmetric_difference() Returns the symmetric difference of two sets as a new set
symmetric_difference_update() Updates a set with the symmetric difference of itself and another


Fuente : https://www.geeksforgeeks.org/python-sets/