Think first that you need to read documentation. If you open a Python tutorial and then try to find information about OrderedDict you will see the following:
class collections.OrderedDict([items]) - Return an instance of a dict
subclass, supporting the usual dict methods. An OrderedDict is a dict
that remembers the order that keys were first inserted. If a new entry
overwrites an existing entry, the original insertion position is left
unchanged. Deleting an entry and reinserting it will move it to the
end.
New in version 2.7.
So in case you are using an ordered dictionary and you are not going to delete keys - then 'animal' will be always in the position you add - e.g. index 2.
Also to get an index of a 'cat' you can simply use:
from collections import OrderedDict
d = OrderedDict((("fruit", "banana"), ("drinks", "water"), ("animal", "cat")))
d.keys()
>>> ['fruit', 'drinks', 'animal']
d.values()
>>> ['banana', 'water', 'cat']
# So
d.values().index('cat')
>>> 2
# Here is lambda
getPos = lambda oDict, toFind, byKey=True: list(oDict.keys() if byKey else oDict.values()).index(toFind)
# Now you can do the following
>>> getPos(d, 'animal')
>>> 2
>>> getPos(d, 'cat', False)
>>> 2
>>> getPos(d, 'water', False)
>>> 1