how to count chars in string python3 code example Example: count characters in string python >>> sentence = 'Mary had a little lamb' >>> sentence.count('a') 4