w3resource

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: Built-in-function - frozenset() function

Python Code Editor:

Previous: format()
Next: getattr()

Test your Python skills with w3resource's quiz



Become a Patron!

Follow us on Facebook and Twitter for latest update.

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://www.w3resource.com/python/built-in-function/frozenset.php