I'm struggling on the code to link two python dictionaries together:
d1 = {'a':'Apple','b':'Banana'}
d2 = {'Apple':'Pomme','Banana':'Banane'}
I want to create a new dictionary d3 where 'a' is a key for the value 'Pomme' and 'b' is the key for value 'Banane'.
d3 = {'a':'Pomme','b':'Banane'}
Any guidance would be greatly appreciated.
Using a dictionary comprehension:
d3 = {k: d2[v] for k, v in d1.items()}
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