Loading...
Python

frozenset Data Type

It is same as set except that is is immutable.
So, we cannot use add or remove functions.

  1. 1.>>>a={5,10,15,20}
  2. >>>fs=frozenset(a)
  3. >>>type(fs)
  4. <class ‘frozenset’>
  5. >>>fs
  6. frozenset({20,10,5,15})
  7. >>>for i in fs:print(i)
  8. ……….
  9. 20
  10. 10
  11. 5
  12. 15
  13. >>>fs.add(70)
  14. AttributeError: ‘frozenset’ object has no attribute ‘add’
  15. >>>fs.remove(10)
  16. AttributeError:’frozenset’ object has no attribute remove,
Leave a Reply

Your email address will not be published. Required fields are marked *