I want to be able to print the top three values in a dictionary created in another function, where there may be repeating values.
For example, if I have a dictionary d = { a:1, b:2, c:3, d:3, e:4 } I would only want a, b, and c returned.
This is what I currently have, but the output would be a, b, c, d. I don't want to remove d from the dictionary, I just don't want it returned when I run this function.
def top3(filename: str):
    """
    Takes dict defined in wd_inventory, identifies top 3 words in dict
    :param filename:
    :return:
    """
    d = max_frequency(filename)
    x = list(d.values())
    x.sort(reverse=True)
    y = set(x)
    x = x[0:3]
    for i in x:
        for j in d.keys():
            if d[j] == i:
                print(str(j) + " : " + str(d[j]))
    return
 
     
     
    