Python Tutorial · Revision notes

Python Sets

A set is an unordered collection of unique items. You will learn creation, mathematical set operations, the set methods, and how a set differs from a dictionary.

Quick revision

  • Set = unique, unordered, mutable, hashable items
  • Empty set is set(), {} is dict
  • | & - ^ operators and their methods
  • remove raises KeyError; discard does not
  • No indexing on sets
  • Set holds items; dict holds key:value pairs
Read the full Python Sets notes on Doubtclip →