__peter__ at web.de
Sun Jul 29 13:08:57 CEST 2012
subhabangalore at gmail.com wrote:
> Dear Group,
> I was trying to convert the list to a set, with the following code:
> the code was running fine, but all on a sudden started to give the
> following error,
> TypeError: unhashable type: 'list'
> please let me know how may I resolve.
> And sometimes some good running program gives error all on a sudden with
> no parameter changed, how may I debug it?
Add a print statement before the offending line:
set1 = set(list1)
You will see that list1 contains another list, e. g. this works...
>>> list1 = ["alpha", "beta"]
...while this doesn't:
>>> list1 = ["alpha", ["beta"]]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
More information about the Python-list