I have this ordered dict od
:
OrderedDict([('and', 1), ('that', 1), ('this', 1), ('of', 1), ('truly', 1), ('something', 1), ('nothing', 1), ('important', 2), ('is', 3)])
I am trying to print the key value pairs of this dictionary in the reverse order. I tried this:
for k,v in od.items()[-1:]:
print k,v
It prints:
is 3
But it prints only the last key value pair i.e. ('is',3)
. I want all the key value pairs in the reverse order like:
is 3
important 2
nothing 1
something 1
truly 1
of 1
this 1
that 1
and 1
Is there a way?