count occurrences of character in string python 3 code example Example: python count character occurrences str1.count("a")