If keys and values are unique you could do this...

--------------

#         Left      : Right
roman = { "One"     : "I",
          "Two"     : "II",
          "Three"   : "III",
          "Four"    : "IV",
          "Five"    : "V",
          "Six"     : "VI",
          "Seven"   : "VII",
          "Eight"   : "VIII",
          "Nine"    : "IX",
          "Ten"     : "X" }

left, right = zip( *roman.items() )
left = list(left)
right = list(right)

print left[ right.index("VIII") ]

--------------

... result is "Eight".

Hmmm! zip returns tuples, which need to be turned into lists to do
much with. Maybe not the best solution in this case.

Verse.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to