Member-only story

Python Programming Language: Sets Functions

Jesse L
2 min readSep 19, 2021

--

Hi everyone, welcome back. Sets are a data structure in the Python language capable of storing several items in a singular set variable. Sets are a built in data type in Python and we will go over the functions regarding sets. For a more in depth tutorial on Sets in Python, click here.

Sets Functions

  • add(): adds an item into the set
  • clear(): removes every item from the set
  • copy(): retrieves a copy of the set
  • difference(): retrieves a new set containing the difference between two sets
  • difference_update(): removes items in the current set that are also in another given set
  • discard(): removes a specified item from the set
  • intersection(): retrieves a new set that contains the items that appear from two different sets
  • intersection_update(): removes items in the current set that are not present in another given set
  • isdisjoint(): checks if two sets have a shared item or not
  • issubset(): checks if the current set is a subset of another given set
  • issuperset(): checks if the current set is a superset of another given set
  • pop(): removes an item from the set
  • remove(): removes a specified item from the set
  • symmetric_difference(): retrieves a set with symmetric differences from two sets
  • symmetric_differences_update(): adds the symmetric difference from the current set to another given set
  • union(): retrieves a new set with items from two given sets
  • update(): updates the current set with another given set or iterable

--

--

Jesse L
Jesse L

Written by Jesse L

Hi, I'm a passionate technology enthusiast and lifelong learner. Beyond my technical pursuits, I'm also passionate about sharing my enthusiasm with others.

No responses yet