How to change dictionary values with map function in Python

1 Answer

0 votes
dic = {234 : 'python', 8762: 'java', 3: 'php', 18: 'c', 200 : 'c++'}

dic = dict(map(lambda i: (i[0] + 3, i[1] + '_OK'), dic.items() ))
 
print(dic)



'''
run:

{237: 'python_OK', 8765: 'java_OK', 6: 'php_OK', 21: 'c_OK', 203: 'c++_OK'}

'''

 



answered Feb 2, 2020 by avibootz
...