#Use the builtin frozenset function
empty_frozenset = frozenset()

f = frozenset([1, 2, 3, 4])

The frozenset() function is used to create an immutable frozenset object.  A frozenset is an unordered collection of unique elements, similar to a set, but it is immutable, meaning its elements cannot be modified once it is created.

The frozenset() function takes an iterable as its argument and returns a new frozenset object containing the elements from the iterable. If no argument is provided, an empty frozenset is returned.


frozenset(iterable = None)
iterable The iterable argument to be casted into a frozenset. If it is not given, an empty frozenset will be returned.

If no argument is given, the function returns an empty frozenset. Otherwise, the function returns a frozenset with all the unique elements from the given iterable.

empty_frozen_set = frozenset()
numbers = [1, 2, 3, 4, 5]
frozen_numbers = frozenset(numbers)
//frozenset({1, 2, 3, 4, 5})

string = "hello"
frozen_string = frozenset(string)
//frozenset({'l', 'h', 'o', 'e'})

Frozensets are especially useful when you need an immutable set-like object that can be used as a dictionary key or as an element in another set. Their immutable nature also makes them more efficient than 'normal' sets if we do not intend to modify the resulting set.