set (Python)

An unordered collection of distinct values, written {1, 2, 3} or made with set(), where each value appears only once.

In more detail

Converting a list to a set removes its duplicates, and testing membership with in is very fast however big the set is. Sets have no order and no indices, and their items must be hashable. {} makes an empty dictionary, so write set() for an empty set.

Example

set("mississippi")   # {"m", "i", "s", "p"}

Related terms

Taught in

References