I do have dictionary with descending order of values as below:
d = {'A6': 5, 'A3': 4, 'A2': 4, 'A1': 3, 'A5': 2, 'A10': 1 }
I would like to print the ascending oder of Top 3 keys for the descending order of values (Top 3 values). If the values have the same value appearing in the top 3 list, print those relevant keys as below: Expected Output
A1
A2
A3
A6
I have tried something like below: but I am not successful in getting printed "A1" in the output: >>> d = {'A6': 5, 'A3': 4, 'A2': 4, 'A1': 3, 'A5': 2, 'A10': 1 } >>> for x in sorted(list(d)[0:3]): ... print(x)
... A2 A3 A6