Python frozenset() Function

The frozenset() function in Python is used to create frozenset. For example:

x = (32, 43, 53, 534)
y = frozenset(x)

The output will be:

frozenset({32, 43, 53, 534})

Python frozenset() Function Syntax

The syntax of frozenset() function in Python, is:


where iterable refers to an iterable object like list, tuple, set etc.

Python frozenset() Function Example

The program given below is an example of frozenset() function in Python:

mylist = ["codes", "cracker", "python", "programming"]
fs = frozenset(mylist)

mydict = {"Day": "Sun", "Month": "Nov", "Year": "2021"}
fs = frozenset(mydict)

The snapshot given below shows the sample output produced by this Python program, demonstrating the frozenset() function:

python frozenset function

Python Online Test

« Previous Function Next Function »

Like/Share Us on Facebook 😋