• + 0 comments

    I did this:

    s = input().lower()
    
    # Create dictionary of each char count
    dict = {char: s.count(char) for char in s}
    
    # Return list of tuples by value count in descending order, and alphabetic for equal values
    sorted_list = sorted(dict.items(), key = lambda x: (-x[1], x[0]))
    
    # Print top three values of sorted_list
    for key, value in sorted_list[:3]:
        print(key, value)