How to use counter to get the most common letters from a string in Python

1 Answer

0 votes
from collections import Counter

counter = Counter()
for ch in "python programming language":
    counter[ch] += 1

lst = counter.most_common()

for item in lst:
    if (item[1] > 2):
      print(item[0], item[1])



'''
run:

g 4
n 3
a 3
 
'''

 



answered Jul 26, 2019 by avibootz

Related questions

...