How to invert a dictionary change the values to keys and the keys to values in Python

1 Answer

0 votes
language = {'python': 13, 'php': 50, 'java': 6}

inverted_dic = {}

for key, value in language.items():
    inverted_dic[value] = key

print(inverted_dic)

'''
run:

{50: 'php', 13: 'python', 6: 'java'}
  
'''

 



answered Aug 29, 2018 by avibootz
...