The hash() function returns the hash value for the given object. With that function, there are two ways to test if an object is hashable:
- Using a
try/exceptblock; - Using the
isinstance()function withtyping.Hashable.
try/except Block
You could also try to add the object to a set instead of using the hash() function.