python count occurrence of char in string code example
Example 1: count characters in string python
>>> sentence = 'Mary had a little lamb'
>>> sentence.count('a')
4
Example 2: python count character occurrences
str1.count("a")
>>> sentence = 'Mary had a little lamb'
>>> sentence.count('a')
4
str1.count("a")