Python frozenset() Function
Example
Freeze the list to make it immutable:
mylist = ['apple', 'banana', 'cherry'] x = frozenset(mylist)
Definition and Usage
The frozenset() function returns an immutable Frozenset object (similar to set objects, but not modifiable).
Syntax
frozenset(iterable)
Parameter Value
Parameter | Description |
---|---|
iterable | Iterables, such as lists, sets, tuples, etc. |
More Examples
Example
Attempt to change the value of the Frozenset item.
This will cause an error:
mylist = ['apple', 'banana', 'cherry'] x = frozenset(mylist) x[1] = "strawberry"