Good day! I can’t find information on the network about whether this is possible:'word3'} b={SomeFunc(x): AnotherFunc(y) for x, y in a} #created a dictionary where it was applied to keys and/or values ​​of the function
I don’t want to cycle through the loop, the generators are much more beautiful.
How beautiful to implement?
  • in a.items() – Robot Hovercraft Apr 4 '17 at 01:32
  • Robot Hovercraft: In! Thank you very much. It is even a shame that such an elementary thing did not take into account.... – Horrifying11 Apr 4 '17 at 01:48

1 Answers 1

Try a bolder attempt:
a={'key1':'word1','key2':'word2','key3':'word3'}
b={key.upper(): value[:: - 1] for key, value in a.items()}

Output:
{'KEY1':'1drow','KEY3':'3drow','KEY2':'2drow'}
  • thank! Languages ​​in the head interfere, several projects on the shoulders, such an elementary thing did not understand – Horrifying11 Apr 4 '17 at 01:49