count number of occurrences of item in string python code example
Example 1: python count character occurrences
str1.count("a")
Example 2: python count occurrences of an item in a list
>>> [1, 2, 3, 4, 1, 4, 1].count(1)
3
str1.count("a")
>>> [1, 2, 3, 4, 1, 4, 1].count(1)
3