Python frozenset() Function

Last Updated : 18 Apr 2026

The python frozenset() function returns an immutable frozenset object initialized with elements from the given iterable.

Syntax of frozenset() Function

It has the following Syntax:

Parameters

  • iterable: An iterable object such as list, tuple etc.

Return Values

It returns an immutable frozenset object initialized with elements from the given iterable.

Examples of frozenset() Function

Here, we are going to discuss several examples to demonstrate the working of frozenset() function.

Example 1: frozenset() Function Example with Tuple

In this example, a tuple of elements is converted into an immutable set using the frozenset() function.

Output:

Frozen set is: frozenset({'o', 'm', 's', 'r', 't'})
Empty frozen set is: frozenset()

Explanation:

In the above example, we take a variable that consists tuple of letters and returns an immutable frozenset object.

Example 2: Using frozenset()function with dictionaries

The below example shows the working of frozenset() with dictionaries.

Output:

Frozen set is: frozenset({'name', 'sex', 'age'})