Python Practice › Set Programs › Program 36
Is a value a frozenset?
Write a Python program to check whether a value is a frozenset.
Input
frozenset({1, 2}), {1, 2}Output
frozenset True set False
Approach
isinstance(x, frozenset).
Solution
for x in [frozenset({1, 2}), {1, 2}]: print(type(x).__name__, isinstance(x, frozenset))Output
frozenset True set False
Learn the concept
New to this topic? Read the lesson, then come back.