39 of 151 menu

The frozenset function

The function frozenset transforms a set into immutable. In the function parameter we specify the set that we need to make immutable.

Syntax

frozenset(set)

Example

Let's make our set immutable:

st = {'a', 'b', 'c'} res = frozenset(st) print(res)

Result of code execution:

frozenset({'a', 'b', 'c'})

See also

  • method add,
    which adds elements to a set
  • method remove,
    which removes elements from a set
  • function len,
    which returns the length of the set
byenru