Python newbie here and wanted to know if there was a way to combine two lists into a dictionary in a way where value can be a specific number. Here’s an example of the 3 datasets I’m trying to combine:
[17, 39, 9] [13, 37, 13] = 0.13517353359
[17, 39, 9] [15, 38, 10] = 0.055003044449
[13, 39, 13] [13, 37, 13] = 0.0345037548204
[13, 39, 13] [15, 38, 10] = 0.0801704891415
[14, 39, 12] [13, 37, 13] = 0.0596711995129
[14, 39, 12] [15, 38, 10] = 0.055003044449
[15, 39, 11] [13, 37, 13] = 0.0848386442054
[15, 39, 11] [15, 38, 10] = 0.0298355997564
[16, 39, 10] [13, 37, 13] = 0.110006088898
[16, 39, 10] [15, 38, 10] = 0.0298355997564
I really want to be able to sort the numbers(I have a function that does this working already) and want to lookup by the first list(but need the second list as a reference).
I thought of doing something like name = "%s-%s" % ([16, 39, 10], [15, 38, 10]) then adding name to a dict(with the number being the value) but the problem with this I couldn’t search [16, 39, 10] to get the result. I could make a dict like {[16, 39, 10]:[[15, 38, 10], 0.0298355997564]} but then my search function breaks.
I suspect I might have to do something wonky, but I was wondering if there was a better way to approach this? Ideally I want a simple dict like {[16, 39, 10]:0.0298355997564} and [15, 38, 10] being some kind of attribute that I can reference when needed).
Is this possible?
edit: more details: I need it(reference, second list) there in case I need to reference it later(in this specific example, when I come across a duplicate for [16, 39, 10] I would use the second list to differinate between the results but in my full dataset there aren’t many duplicates so its just to refer to in specific cases).
Lists can’t be dictionary keys, since they are mutable. If the data is static you can convert it to a tuple and use that as a key. The values can also be a tuple of the second list and float value.