if __name__ == '__main__':
    test_string = 'cnaa'
string_dict = dict()
for letter in test_string:
    if letter not in string_dict:
        string_dict[letter] = test_string.count(letter)
ordered_answer = sorted(list(string_dict.items()), key=operator.itemgetter(1),
    reverse=True)
print(ordered_answer)
How to write a function that takes a string and prints the letters in decreasing order of frequency?