join dictionaries using keys from one & values

danplawson at gmail.com danplawson at gmail.com
Tue Dec 6 13:52:35 EST 2005


Super simple:

dict3 = {}
for k1 in dict1.keys():
    for k2 in dict2.keys():
        if dict1.get(k1) == dict2[k2]:
            dict3[k1] = k2

works in all cases and can be simplified to an iterated dictionary in
python 2.4




More information about the Python-list mailing list