1#printing the number of characters in a string
2print(len("String you want to count"))
3
4#counting characters in a variable
5a = "some string"
6print(len(a))
1string.count(substring, start=..., end=...)
2
3'recede'.count('e')
4>>> 3
5'recede'.count('e', 2, 4)
6>>> 1
1def count_substring(string,sub_string):
2 l=len(sub_string)
3 count=0
4 for i in range(len(string)-len(sub_string)+1):
5 if(string[i:i+len(sub_string)] == sub_string ):
6 count+=1
7 return count
8