Python Frozenset

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

>>> fs=frozenset([26,79,37,58,10,63])

>>> print(fs)
frozenset({58, 37, 10, 79, 26, 63})
>>> print(type(fs))
<class 'frozenset'>
>>> fs.add(57)
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
fs.add(57)
AttributeError: 'frozenset' object has no attribute 'add'
>>> fs1=frozenset([66,58,33,75,10])
>>> print(fs.union(fs1))
frozenset({33, 66, 58, 37, 10, 75, 79, 26, 63})
>>> print(fs.intersection(fs1))
frozenset({10, 58})

You might also like