Hi I have two dictionary as follows
{'abc':1,'xyz':8,'pqr':9,'ddd': 22}
{0:'pqr',1:'xyz',2:'abc',3:'ddd'}
My objective is to get a new dictionary in the following format
{2:1 1:8 0:9 3:22}
I am combing the value of first dictionary as value of the new dictionary and the key of dictionary 2 whose value matches with the key of the dictionary 1 as key of the the new dictionary.
I have written some code as follows:
for list1elem in listofemail[1:]:
print(list1elem)
for the_key, the_value in list1elem.items():
the_key = [k for k, v in vocab_dic.items() if v == the_key]
But my code is not replacing the old key with the new one. Both of my dictionaries are large, containing 25000 key/value pair. So it is taking a lot of time. What would be the fastest way to do this?