/ Published in: Python

Based on the example by [Mark Pilgrim](http://diveintopython3.org/about.html).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
dict = {'a': 1, 'b': 2, 'c': 3} print({value:key for key, value in dict.items()}) # Prints: {1: 'a', 2: 'b', 3: 'c'}
URL: http://diveintopython3.org/comprehensions.html#stupiddicttricks
Comments
