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
Python: Tips of the Day
How do I check if a list is empty?
For example, if passed the following:
a = [] if not a: print("List is empty")
Ref: https://bit.ly/2A4JXx9
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework