1message = 'python is popular programming language'
2
3# number of occurrence of 'p'
4print('Number of occurrence of p:', message.count('p'))
5
6>>> Number of occurrence of p: 4
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