Language Syntax

Set display — Python syntax

Construct a set from hashable elements, collapsing duplicates. A nonempty brace display without key-value pairs or double-star mappings creates a set; empty braces create a dictionary. Use set() for an empty set.

Formal Syntax & Structure

python syntaxpython
{expression, *iterable, ...}

Return Value

set

Value obtained by evaluating this expression; see description for context and constraints.

Working Example

Example Snippetpython
values={1,2,1,*[3,2]}print((sorted(values),type({}).__name__))
Python Reference