Python frozenset() FunctionPython Functions


The frozenset() function returns an immutable frozenset object which is like an immutable set object.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

List1 = ['1', 'A', '2','B','C','D']
x = frozenset(List1)
print(List1)
x[1] = "strawberry"

Output:

Traceback (most recent call last):
TypeError: 'frozenset' object does not support item assignment

Syntax

frozenset(object)

Parameters

Name Description
object An iterable object, like list, set, tuple, etc.

Return Value

It returns an immutable frozenset object.

© 2021 Programtips.org, all rights reserved. Privacy Policy | Contact Us