Python Practice › Set Programs › Program 36

Is a value a frozenset?

EasySet Programs · 36 of 48

Write a Python program to check whether a value is a frozenset.

Advertisement
Input
frozenset({1, 2}), {1, 2}
Output
frozenset True
set False

Approach

  1. isinstance(x, frozenset).

Solution

Python
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.

More set programs

← All 48 Set Programs

Leave a Comment