Easy Tutorial
❮ Python Func Number Degrees Python Func Ascii ❯

Python frozenset() Function

Python Built-in Functions


Description

frozenset() returns an immutable set. Once a set is frozen, it cannot have any elements added or removed.

Syntax

The syntax for the frozenset() function is:

class frozenset([iterable])

Parameters

Return Value

Returns a new frozenset object. If no parameters are provided, it defaults to an empty set.

Example

The following example demonstrates the use of frozenset():

>>>a = frozenset(range(10))     # Creates a new immutable set
>>> a
frozenset([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> b = frozenset('tutorialpro') 
>>> b
frozenset(['b', 'r', 'u', 'o', 'n'])   # Creates an immutable set
>>>

Python Built-in Functions

❮ Python Func Number Degrees Python Func Ascii ❯