Aug-20-2020, 02:46 PM
these are 2 different errors
the first one - TypeError: unhashable type: 'set' - you get because elements of a set MUST be hashable.
the second error - TypeError: 'set' object is not subscriptable - you have a dict where values are set. You try to access element of such set (the value for key 'cars') by index - that is not possible. sets are not subscriptable (i.e. you cannot use [] to access element), they are unordered collection
the list of list example does not raise any error - it's perfectly fine to have unhashable element in a list
the first one - TypeError: unhashable type: 'set' - you get because elements of a set MUST be hashable.
the second error - TypeError: 'set' object is not subscriptable - you have a dict where values are set. You try to access element of such set (the value for key 'cars') by index - that is not possible. sets are not subscriptable (i.e. you cannot use [] to access element), they are unordered collection
the list of list example does not raise any error - it's perfectly fine to have unhashable element in a list
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs