Python frozenset() Method
Python frozenset() method is a built-in method. It returns a frozenset object from the given iterable. Itrerable can be a list, set, tuple etc. Frozenset is an immutable version of set that does not allow to change its elements.
Signature
Parameter | Description |
---|---|
iterable | (Optional) This single parameter can be a list, tuple, set etc. |
Return Value
  If argument is given, it returns frozenset.
  If no argument is given, it returns empty set.
Python frozenset() Method Example
Let’s first understand, how this method works and what does it return?
See, in the above example, we created a list and applied frozenset() method. We checked type of list before and after applying method. See, the type of list is changed because the method frozenset() returns a frozenset object.
Python frozenset() Method Example
As we said, frozenset is immutable that means you can't modify it. It throws an error if you modify it. See, an example below.
TypeError: 'frozenset' object does not support item assignment