The python frozenset() function returns an immutable frozenset object initialized with elements from the given iterable.
It has the following Syntax:
It returns an immutable frozenset object initialized with elements from the given iterable.
Here, we are going to discuss several examples to demonstrate the working of frozenset() function.
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.
The below example shows the working of frozenset() with dictionaries.
Output:
Frozen set is: frozenset({'name', 'sex', 'age'})
We request you to subscribe our newsletter for upcoming updates.