Reputation: 155
I have a dict (dict_genes) containing gene id's as the keys.
I want to iterate through this dict and use the gene id's (keys) to extract values from another dict (seq_depth) such as:
for key, value in dict_genes.items():
print(seq_depth[key])
The dict seq_depth contains several identical gene id's and with this approach only one occurrence is printed where I want all of the gene id's printed if the match the key in the iteration (including indenticals).
Upvotes: 0
Views: 92
Reputation: 19264
For dictionaries you cannot have more than one of the same key. Instead, I would suggest using a dictionary whose keys point to lists of values:
seq_depth = {"id": ["item1", "item2", "item3"]}
Upvotes: 1