/ Published in: Python
URL: http://diveintopython3.org/comprehensions.html#stupiddicttricks
Based on the example by Mark Pilgrim.
Expand |
Embed | Plain Text
dict = {'a': 1, 'b': 2, 'c': 3} print({value:key for key, value in dict.items()}) # Prints: {1: 'a', 2: 'b', 3: 'c'}
You need to login to post a comment.
