Python Forum

Full Version: You have any idea, how fix TypeError: unhashable type: 'list'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
from pcpartpicker import API

You have any idea, how to print api.supported_parts where

api = API()

You have any idea, how fix TypeError: unhashable type: 'list'??????????????

Python 3.8.6 (c:\users\lwdls\appdata\local\programs\python\python38\python.exe)
>>> %Run pcpartpicker5.py
Traceback (most recent call last):
File "D:\DOWNLOADS\Textbooks - Source Code\Python 3 Thonny IDE\pcpartpicker5.py", line 4, in <module>
from pcpartpicker import API
TypeError: unhashable type: 'list'
>>>


[Image: h2I81SjQmfr6EA]
Please, post the full code (minimal reproducible example) as well as full traceback you get.
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
(Jun-01-2021, 07:21 PM)lsepolis123 Wrote: [ -> ]from pcpartpicker import API

You have any idea, how to print api.supported_parts where

api = API()

You have any idea, how fix TypeError: unhashable type: 'list'??????????????

Python 3.8.6 (c:\users\lwdls\appdata\local\programs\python\python38\python.exe)
>>> %Run pcpartpicker5.py
Traceback (most recent call last):
File "D:\DOWNLOADS\Textbooks - Source Code\Python 3 Thonny IDE\pcpartpicker5.py", line 4, in <module>
from pcpartpicker import API
TypeError: unhashable type: 'list'
>>>


[Image: h2I81SjQmfr6EA]

Now this is just a guess, but I would guess that a list is not a hashable entity.

From:

https://docs.python.org/3/glossary.html#term-hashable

Quote:Most of Python’s immutable built-in objects are hashable; mutable containers (such as lists or dictionaries) are not; immutable containers (such as tuples and frozensets) are only hashable if their elements are hashable. Objects which are instances of user-defined classes are hashable by default. They all compare unequal (except with themselves), and their hash value is derived from their id().

Yep, lists are not hashable.