[Tutor] TypeError: dict objects are unhashable
Hugo González Monteverde
hugonz-lists at h-lab.net
Fri Mar 24 17:37:13 CET 2006
Ben Vinger wrote:
> But I get:
> TypeError: dict objects are unhashable
> Unfortunately, I just can't see what I'm doing wrong
>
InnerDict = {}
InnerDict[U] = P
accounts[InnerDict] = U
Your logic is not right somewhere around this. I do not have a lot of
context, nor the full error message, but what it says is that you
*cannot* use a dictionary as a key for a dictionary.
In this line:
accounts[InnerDict] = U
this is what you're doing.
You should be using a dictionary with the tuple, something like this:
InnerDict = {}
InnerDict[U] = P
accounts[(U, P])] = U
Again, I do not wuite get why you want to do it like that. If you could
explain a bit more to us....
Hugo
More information about the Tutor
mailing list