I have multiple lists of tuples eg
[([1, 2, 3, 4], 2), ([5, 6, 7], 3)]
that I would like to have as keys to a dictionary (so each key in my dictionary would be a list of tuples).
Unfortunately, according to the TypeError I’m getting (unhashable type: list), it seems that python doesn’t like hashing lists. All of the elements in my list of tuples are ints (if that makes an difference). Any suggestions on what I can do? Thanks!
Then just use that returned value as your key. Note that I did it this way so you could support even more deeply nested mixes of tuples and lists, like
[([1,(2, [3, 4, [5, 6, (7, 8)]]), 3, 4], 2), ([5, 6, 7], 3)]:There may possibly be a simpler way to do this, though.