check how many of a character is in a string python 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")