Python Forum
You have any idea, how fix TypeError: unhashable type: 'list' - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: You have any idea, how fix TypeError: unhashable type: 'list' (/thread-33850.html)



You have any idea, how fix TypeError: unhashable type: 'list' - lsepolis123 - Jun-01-2021

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]


RE: You have any idea, how fix TypeError: unhashable type: 'list' - buran - Jun-01-2021

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.


RE: You have any idea, how fix TypeError: unhashable type: 'list' - supuflounder - Jun-02-2021

(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.