Python frozenset() Function

Last Updated : 17 Mar 2025

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

Python frozenset() Function Syntax

It has the following Syntax:

Parameters

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

Return

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

Different Examples for Python frozenset() Function 

Here, we are going to discuss several examples for Python frozenset() function.

Python frozenset() Function Example 1

The below example shows the working of the frozenset() function in Python.

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.

Python frozenset() Function Example 2

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

Output:

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