Properties of a Set {}

What are the main properties of a Python set?

Answer
  • Unordered (hence not indexable)

  • Mutable (we can add, remove elements but not change them)

  • Unhashable, however, its elements must be hashable

  • No duplicates (all elements are unique)

  • Heterogeneous (i.e., can store different data types)

Notes and comments

Comment 1: For Python's built-in data structures, being ordered implies that the structure is indexable ([]).

Back to collection