Program excercise : Write a function that takes a dictionary with numeric values and returns the keys of the top 3 highest values.

def get_top3_values_indices(input_dict, col_range=3):
    all_values = list(set(input_dict.values()))
    all_values.sort(reverse=True)
    top_values = all_values[:col_range]
    return [k for k in input_dict.keys() if input_dict[k] in top_values]

Comments

Popular posts from this blog

How to Install minikube in local mac machine?

Program excercise : Write a function that, using the Star Wars API (swapi.co), takes a character name, and returns a list with the names of the films that character was in.