KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I receive a dictionary as input, and would like to to return a dictionary whose keys will be the input's values and whose value will be the corresponding input keys. Values are unique. For example, say my input is: a = dict() a['one']=1 a['two']=2 I would like my output to be: {1: 'one', 2: 'two'} To clarify I would like my result to be the equivalent of the following: res = dict() res[1] = 'one' res[2] = 'two' Any neat Pythonic way to achieve this?
Tags (comma-separated)
Save Edits
Cancel