python count all occurrences in string code example
Example 1: count in python string
string.count(substring, start, end)
# Start and end is optional
Example 2: count characters in string python
>>> sentence = 'Mary had a little lamb'
>>> sentence.count('a')
4
Example 3: python count character occurrences
str1.count("a")