join dictionaries using keys from one & values

ProvoWallis gshepherd281 at earthlink.net
Mon Dec 5 23:27:23 EST 2005


I'm still learning python so this might be a crazy question but I
thought I would ask anyway. Can anyone tell me if it is possible to
join two dictionaries together to create a new dictionary using the
keys from the old dictionaries?

The keys in the new dictionary would be the keys from the old
dictionary one (dict1) and the values in the new dictionary would be
the keys from the old dictionary two (dict2). The keys would be joined
by matching the values from dict1 and dict2. The keys in each
dictionary are unique.

dict1 = {1:'bbb', 2:'aaa', 3:'ccc'}

dict2 = {5.01:'bbb', 6.01:'ccc', 7.01:'aaa'}

dict3 = {1 : 5.01, 3 : 6.01, 2 : 7.01}

I looked at "update" but I don't think it's what I'm looking for.

Thanks,

Greg




More information about the Python-list mailing list