Python select ith element in OrderedDict
I have a snippet of code which orders a dictionary alphabetically. Is there a way to select the ith key in the ordered dictionary and return its corresponding value? i.e. import collections initial = dict(a=1, b=2, c=2, d=1, e=3) ordered_dict = collections.OrderedDict(sorted(initial.items(), key=lambda t: t[0])) print(ordered_dict) OrderedDict([('a', 1), ('b', 2), ('c', 2), ('d', 1), ('e', 3)]) I want to have some function along the vein of... select = int(input("Input dictionary index")) #User inputs 2 #Program looks up the 2nd entry in ordered_dict (c in this case) #And then returns the