Mar-06-2019, 10:01 PM
from collections import Counter import string test_string = 'Sentence Statistics' counter = Counter(test_string) for item, count in counter.most_common(): if item in string.ascii_letters: print(f'{item} appeared {count} times')
Output:t appeared 4 times
e appeared 3 times
S appeared 2 times
n appeared 2 times
c appeared 2 times
i appeared 2 times
s appeared 2 times
a appeared 1 times