frozenset()

fronzenset(my_iterable)
my_iterable : This is an iterable object like List, tuple, set Output is unchangeable frozenset object. This object is immutable ( what is immutable ? )

Using List
my_list=[1,2,3]
my_list=frozenset(my_list)
print(my_list) # frozenset({1, 2, 3})
We will try to change one element
my_list=[1,2,3]
my_list=frozenset(my_list)
my_list[1]=8
print(my_list) # frozenset({1, 2, 3})
Above code will generate error saying TypeError: 'frozenset' object does not support item assignment

Using tuple
my_tuple=(1,2,3)
my_tuple=frozenset(my_tuple)
my_tuple[1]=5
Above code will generate error saying TypeError: 'frozenset' object does not support item assignment

One more example
my_tuple=(1,2,3)
my_tuple +=(4,5)
print(my_tuple)
my_tuple=frozenset(my_tuple)
my_tuple +=(6,7)
Above code will generate error saying TypeError: unsupported operand type(s) for +=: 'frozenset' and 'tuple'

Python


Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2023 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer