ShareYourGroupShareYourGroupError Explainer

Python TypeError: unhashable type: 'list'

A plain-words explanation of this Python message: what it means, the usual causes, and the steps that fix it.

The messageTypeError: unhashable type: 'list'

Make the error yourself

Run with Python 3.14.10. This is the smallest example we could find that shows it.

Python program (main.py)

points = {[1, 2]: "A"}
print(points)

Output (the real message)

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    points = {[1, 2]: "A"}
             ^^^^^^^^^^^^^
TypeError: cannot use 'list' as a dict key (unhashable type: 'list')

Why it happens

Dictionary keys and set members must have a fixed "hash", a number that never changes for the same value. Lists can change (you can add items), so Python does not allow them as keys. The same error appears when you put a list or a dictionary into a set. Tuples, strings and numbers are fixed and can be keys.

How to fix it

  1. Use a tuple instead of a list: (1, 2).
  2. Convert when needed: tuple(my_list).
  3. If you need to look something up by a list's contents, join them into a string first: ",".join(...).
  4. For a set of lists, use a set of tuples.

The corrected version

Python program (main.py)

points = {(1, 2): "A"}
print(points)
print({tuple([1, 2]): "A"})

Output (the corrected version)

{(1, 2): 'A'}
{(1, 2): 'A'}

How to avoid it

Keep keys simple: strings, numbers, or tuples of those.

Questions

Can a tuple contain a list and still be a key?

No. A tuple is hashable only if everything inside it is hashable.

This is an independent guide. It is not connected with Python, Microsoft, Google, GitHub or the Git project. Product names belong to their owners. Examples were run on 13 November 2026 in a practice folder or a blank workbook; your version may word a message slightly differently.