Loading lesson path
Python frozenset frozenset is an immutable version of a set. Like sets, it contains unique, unordered, unchangeable elements. Unlike sets, elements cannot be added or removed from a frozenset.
constructor to create a frozenset from any iterable.
Create a frozenset and check its type:
x = frozenset({"apple", "banana", "cherry"})
print(x)
print(type(x))Being immutable means you cannot add or remove elements. However, frozensets support all non-mutating operations of sets.
Try it » difference()
Try it » intersection() &
Try it » isdisjoint()
Try it » issubset() <= / < Returns True if this frozenset is a (proper) subset of another Try it » issuperset() >= / > Returns True if this frozenset is a (proper) superset of another Try it » symmetric_difference() ^ Returns a new frozenset with the symmetric differences Try it » union() |
Try it »