I have a dictionary with 46,000 key:value pairs where each key has a 3 item list as values:
my dict = {key1: ['A', 'B', 'C'], key2: ['B', 'A', 'G'], key3: ['Z', 'H', 'I']......}
I have a list with hundreds of values:
L1 = ['A', 'A', 'B', 'D', ......]
How do I iterate through the list L1 and for each item in L1, match each dictionary value where value[0] matches the list item? I then wish to perform other operations on value[1] and value[2] of the dictionary only on those key:value pairs where a list item matched value[0] in the dictionary.
In the above example, the first item in L1 – ‘A’ would match only key1: ['A', 'B', 'C'].
I can’t seem to figure out a way to do this? Thanks for the help!
Without any shortcuts, you could write something like this: