Can OrderedDict get a key position?
is like list of index()
test = ['a', 'b', 'c', 'd', 'e']
test.index('b') # return 1
just one line program. such as:
print(list(your_ordered_dict).index('your_key'))
Maybe you can use lambda,like this line program:
f = lambda ordered_dict, key: list(ordered_dict).index(key)
Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With