Python: frozenset() function
frozenset() function
The frozenset() function returns a new frozenset object, optionally with elements taken from iterable.
Note: frozenset is a built-in class.
Version:
(Python 3.2.5)
Syntax:
frozenset([iterable])
Parameter:
Name | Description | Required / Optional |
---|---|---|
iterable | An iterable object, like list, set, tuple etc. | Required |
Return value:
frozenset object.
Example: Python frozenset() function
# tuple of words
words = ('apple', 'orange', 'mango', 'banana')
froSet = frozenset(words)
print('The frozen set is:', froSet)
print('The empty frozen set is:', frozenset())
Output:
The frozen set is: frozenset({'apple', 'mango', 'orange', 'banana'}) The empty frozen set is: frozenset()
Pictorial Presentation:
Python Code Editor:
Previous: format()
Next: getattr()
Test your Python skills with w3resource's quiz
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/python/built-in-function/frozenset.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics