Home / Python / Reference / Built-in functions

Python frozenset() function

Make a set that cannot be changed.

Syntax

frozenset(iterable=())

Because it is unchangeable, a frozenset can be a dictionary key or an item in another set.

Parameters

iterablethe items

Return value

frozenset

Example

Code

pair = frozenset({"Sita", "Leo"})
meetings = {pair: "Monday"}
print(meetings[frozenset({"Leo", "Sita"})])   # order does not matter

Output

Monday

Related

Learn it step by step in the free lesson Dictionaries & Sets, with exercises that check your answers.