how to count how many times a character appears in a string python code example
Example 1: python return number of characters in string
# Example usage:
your_string = "Example usage"
len(your_string)
--> 13
Example 2: count characters in string python
>>> sentence = 'Mary had a little lamb'
>>> sentence.count('a')
4
Example 3: python count character occurrences
str1.count("a")
Example 4: check how many letters in a string python
#use the built in function len()
len("hello")
#or you can count the characters in a string variable
a = "word"
len(a)