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

1 Answer

0 votes
from collections import Counter

n = 4
lst = Counter('python programming language').most_common(n)

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



'''
run:

g 4
n 3
a 3
p 2
 

 



answered Jul 26, 2019 by avibootz

Related questions

...