Solution :
I had also faced the similar issue in the recent past. I did lot of research on it and found the solution on it. This is the very common problem with the people getting started. Directly coming to the point the gene_name[x]
is the mutable object so you cannot hash it.. To use the object as the key in a dictionary, python needs to use the hash value, and that is the reason behind you facing above error.
More Details :
The Mutable objects are the objects whose value can be changed. For e.g., list
is the mutable object, as you can append to it.And int
is the immutable object, as you can't change it. When you do:
x = 5;
x = 3;
You are not changing the value of x
but you are creating the new object and making x
point to the value.
To resolve your error, you must use the immutable objects as the keys in your dictionary. For e.g.: tuple
, string
, int
.