I have a dictionary that has English words as keys and Finnish words as values. I'm trying to make a function to reverse this dictionary.
For example:
dictionary = {'move':['liikutta'], 'six':['kuusi'], 'fir':['kuusi']}
Expected output:
reverse = {'liikutta':['move'], 'kuusi':['six'], 'kuusi':['fir']}
The codes I'm using:
def reverse_dictionary(dictionary):
reverse = {}
for key, value in dictionary.items():
for i in range(len(value)):
reverse.update({value[i]:[key]})
return reverse
The 2nd item in the dictionary was skipped. I guess it was because the repeated 'kuusi', but I don't know how to solve it.
Output
{'liikutta':['move'], 'kuusi':['fir']}
Thanks all!