Why Lists Can't Be Dictionary Keys
To be used as a dictionary key, an object must support the hash
function (e.g. through hash), equality comparison (e.g. through
eq or cmp)
That said, the simple answer to why lists cannot be used as dictionary
keys is that lists do not provide a valid hash method.
However, using a string representation of the list:
word2index = {'think': [9.56090081e-05], 'apple': [0.00024469]}
print({repr(v):k for k,v in word2index.items()})
OUTPUT:
{'[9.56090081e-05]': 'think', '[0.00024469]': 'apple'}
OR:
Converting the list to a tuple:
print({tuple(v):k for k,v in word2index.items()})
OUTPUT:
{(9.56090081e-05,): 'think', (0.00024469,): 'apple'}
keyin the dict.