Counter
Count items easily.
What is a Counter?
Counter is a dictionary subclass from the collections module built for counting. You give it items and it tallies how many times each appears.
Import it with from collections import Counter.
from collections import Counter
c = Counter(['a', 'b', 'a', 'c', 'a'])
print(c)Counting characters
Pass any iterable, including a string, and Counter counts each element. Strings are counted character by character.
from collections import Counter
c = Counter('mississippi')
print(c)