You can use the Counter() module of the collections class. A Counter is a dict subclass for counting hashable objects. It is a collection where elements are stored as dictionary keys and their counts are stored as dictionary values.
Here is an example:
>>> from collections import Counter>>> a="ababcbacaba">>> Counter(a)Counter({'a': 5, 'b': 4, 'c': 2})
>>> from collections import Counter
>>> a="ababcbacaba"
>>> Counter(a)
Counter({'a': 5, 'b': 4, 'c': 2})