how to count number of occurrences in a string in python with index code example Example: python count character occurrences str1.count("a")