Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python frozenset() Function

Python frozenset() Function

Python built-in function Python built-in function


Description

frozenset() Returns a frozenset. Once frozen, no elements can be added to or removed from the set.

Syntax

frozenset() function syntax:


class frozenset([iterable])

Parameters

Return Value

Returns a new frozenset object. If no arguments are provided, an empty set is generated by default.

Example

The following examples demonstrate how to use frozenset():

a

=

frozenset

(

range

(

10

)

)

Create a new immutable set

a

frozenset

(

[

0

,

1

,

2

,

3

,

4

,

5

,

6

,

7

,

8

,

9

]

)

b

=

frozenset

(

'

runoob

'

)

b

frozenset

(

[

'

b

'

,

'

r

'

,

'

u

'

,

'

o

'

,

'

n

'

]

)

Create an immutable set

Python built-in function Python built-in function