Unhashable type Position *Edit: This is for Python


I was trying to put my get_surrounding_cardinals() into a dictionary as keys, and it kept returning an error:
“Type Position unhashable:”

To fix this you should add the following code to positionals.py, in the class Position at the end after eq is defined:

def hash(self):
return hash((self.x, self.y))

I hope it helps.
If I was the only one with this problem consider me as a newbie:P


Sadly underscores in this forum will distort the code. You of course typed:

def __hash__(self):
    return hash((self.x, self.y))


Yes, thank you. I did not notice that.