There are many ways to do this. Most use a dictionary ( dict ). For example,
count = {} for letter in message: if letter in count: # saw this letter before count[letter] += 1 else: # first time we've seen this - make its first dict entry count[letter] = 1
There are shorter ways to write this, which I'm sure others will point out, but first study this path until you understand it. This applies to very simple operations.
At the end, you can display it with (for example):
for letter in sorted(count): print(letter, count[letter])
Again, there are shorter ways to do this, but this method adheres to very simple operations.
Tim peters
source share