I have a dictionary containing keys that have values containing values such as "13896615011", "330405011", and some can contain multiple value like so: (3012292011, 1292123011)
I am running through a list of possible keys, where i say:
for x in list:
if (x in dict):
found_match = dict.get(x)
print(found_match)
And this gives me these values:
[13896615011]
[330405011]
[3012292011, 1292123011]
[2476681011]
[172450, 3109930011]
and so on.
Now, I have another dictionary that uses the values printed out above as keys, but when I use a for loop to read through each value, it gives me each integer separately like so:
for value in found_match:
print(value)
And it would return, for the first value,
1
3
8
9
and so on, for all values in the list. The reason I want to iterate through found_match is because there can be two values and not just one. I want to append all the possible values returned from my second dictionary that uses the values (e.g 13896615011) as keys- so I can map the values to my first dictionary's original key.
How can I achieve this?
I think this is what you want
found_match=[]
for x in list:
if (x in dict):
found_match.append(dict.get(x))
print(found_match)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With