Skip to main content

Python: Set Method List

 It is an unordered collection of items. Set items are unique and immutable. Python has a set of built-in methods that We can use on sets.

  • add(): It is used to add element in a set.
  • clear(): It is used to remove all elements from the set.
  • copy(): It returns the copy of a set.
  • difference(): It returns a set containing the difference between two or more sets.
  • difference.update(): It removes the items in the set that are also included in another, specified set.
  • discard(): It is used to remove the elements from the set.
  • intersection(): It is used to return the set which is intersection of two or more set.
  • intersection.update(): It is used to  removes the items in the set that are not present in other, specified set.
  • isdisjoint(): It is used to check that two sets are disjoint set or not.
  • issubset(): It is used to check if a set is subset of another set.
  • issuperset(): It is used to check if a set is superset of another set or not.
  • pop(): It is used to remove an element from the set.
  • remove(): It is used to remove the specified element from the set.
  • symmetric_difference(): It returns the set with the symmetric difference of two set.
  • symmetric_difference_update(): It is used inserts the symmetric differences from this set and another.
  • union(): It return a set containing the union of sets.
  • update(): It is used to add element to the set.
Tags
Submitted by devanshi.srivastava on June 20, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.