AlphaCodingSkills

Python - Set Methods


Advertisements

Previous Page Next Page

The Python has a number of methods and functions that are available for use with sets. These methods and functions are listed below in alphabetical order. For more details about any one of these, please visit its page.

Set Methods & Functions
MethodsDescription
add() Adds an element to the set
clear() Removes all the elements from the set
copy() Returns a copy of the set
difference() Returns a set containing the difference between two or more sets
difference_update() Removes the items in this set that are also included in another, specified set
discard() Remove the specified item
intersection() Returns a set, that is the intersection of two other sets
intersection_update() Removes the items in this set that are not present in other, specified set(s)
isdisjoint() Returns whether two sets have a intersection or not
issubset() Returns whether another set contains this set or not
issuperset() Returns whether this set contains another set or not
pop() Removes an element from the set
remove() Removes the specified element
symmetric_difference() Returns a set with the symmetric differences of two sets
symmetric_difference_update() inserts the symmetric differences from this set and another
union() Return a set containing the union of sets
update() Update the set with the union of this set and others
FunctionsDescription
len() Returns total number of elements in the set
set() set function/constructor is used to create set from iterable like list, tuple, set, string, dictionary and range() etc.





Previous Page Next Page