Skip to main content

← All terms · Data structures

Set

Unordered collection of unique hashable values. O(1) membership check.

{1, 2, 3} - {2}

Learn this interactively:

Open lesson lesson-50

Related — Data structures

List comprehensionInline syntax for building a list from another iterable, with optional filter: `Dict comprehensionSame as list comp, but builds a dict: `{k: v for k, v in pairs}`.TupleOrdered immutable sequence. Use for fixed-size records and as dict keys.DictionaryHash map from keys to values. Insertion order preserved since Python 3.7.IterableAnything you can loop over with `for`. Lists, tuples, sets, dicts, strings, fileGeneratorA function with `yield`. Produces values lazily, one at a time — uses constant m