Python frozenset() Function
Description
frozenset()Returns a frozen set. Once frozen, no elements can be added to or removed from the set.
Syntax
The frozenset() function syntax is:
class frozenset([iterable])
Parameters
- iterable -- An iterable object, such as a list, dictionary, tuple, etc.
Return Value
Returns a new frozenset object. If no argument is provided, an empty set is generated by default.
Examples
The following examples demonstrate how to use frozenset():
>>>a = frozenset(range(10)) # Generate a new immutable set
>>> a
frozenset([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> b = frozenset('example')
>>> b
frozenset(['b', 'r', 'u', 'o', 'n']) # Create an immutable set
>>>
Python Built-in Functions