find smallest key in dictionary python code example
Example 1: python find smallest element in dictionary
d = {"A":3, "B":1, "C":100}
# find key with lowest value
best_key = min(d, key=d.get)
print(best_key)
# output: B
Example 2: python get min max value from a dictionary
d = {'A': 4,'B':10}
min_v = min(zip(d.values(), d.keys()))
# min_v is (4,'A')
max_v = max(zip(d.values(), d.keys()))
# max_v is (10,'B')