I have a lot of text, and I need to clasify them to find out the number of letters in a joint word. For example:
aabbccccdde
I want it to show a result like:
a 2 b 2 c 4 d 2 e 1
How do I do that?
word = 'aabbccccdde' d = {l:word.count(l) for l in set(word)} for key in sorted(d): print(key, d[key])
Like this:
from collections import Counter c = Counter('aabbccccdde') # c now looks like Counter({'a': 2, 'b': 2, 'c': 4, 'd': 2, 'e': 1})