Given that by its very nature, the items in an OrderedDict are ordered, one might expect it to have a function similar to the index function of lists. It does not.
What is the most Pythonic / neatest way of mimicing index for an OrderedDict?
Given that by its very nature, the items in an OrderedDict are ordered, one might expect it to have a function similar to the index function of lists. It does not.
What is the most Pythonic / neatest way of mimicing index for an OrderedDict?
It depends what you want the
indexof. If you want the index of a key, you can just do