Simple code that calculates frequency of letters:
from collections import Counter
s = '''
She sells sea-shells on the sea-shore.
The shells she sells are sea-shells, I'm sure.
For if she sells sea-shells on the sea-shore
Then I'm sure she sells sea-shore shells.
'''
print Counter(s)
Result:
Counter({'s': 32, 'e': 29, ' ': 25, 'l': 18, 'h': 16, 'a': 7, 'r': 7, '-': 6, 'o': 6, '\n': 5, '.': 3, 'n': 3, "'": 2, 'I': 2, 'T': 2, '
m': 2, 'u': 2, 't': 2, ',': 1, 'F': 1, 'S': 1, 'f': 1, 'i': 1})
No comments:
Post a Comment