Suppose there is a dictionary
a = {'a':122,'b':123,'d':333,'e':'233'}
Now I want to revert it as its a one-to-one dictionary so we can do that.
What I have tried:
In [67]: ivd=[(v,k) for (k,v) in a.items()]
In [68]: ivd
Out[68]: [(122, 'a'), (123, 'b'), ('233', 'e'), (333, 'd')]
Now may be some how We can convert this ivd
into a dictionary. My questions are
- How to change this
ivd
into a dictionary ? - Is there any more pythonic solution available to do this? which I think it should be there.