Why can a tuple be a dictionary key and a list cannot? Why does a set refuse to hold another set? The answer is one idea, hashing, and it also explains why dictionaries and sets are so fast. Once you know the rule, which is short, the error TypeError: unhashable type stops being a surprise.
More lessons in Complete Python Programming