Answers for "Python - How To Count Occurrences of a Character in a String"

1

how to count the occurrence of a word in string python

# define string
string = "Python is awesome, isn't it?"
substring = "is"

count = string.count(substring)

# print count
print("The count is:", count)
Posted by: Guest on June-05-2020
0

Python - How To Count Occurrences of a Character in a String

print('Mary had a little lamb'.count('a'))
Posted by: Guest on January-28-2022

Code answers related to "Python - How To Count Occurrences of a Character in a String"

Python Answers by Framework

Browse Popular Code Answers by Language