Answers for "find the occurances of the letters in the string in python"

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 find all occurrence in string

pythonCopy#defining string and substring
str1 = "This dress looks good; you have good taste in clothes."
substr = "good"

#occurrence of word 'good' in whole string
count1 = str1.count(substr)
print(count1)

#occurrence of word 'good' from index 0 to 25
count2 = str1.count(substr,0,25)
print(count2)
Posted by: Guest on November-25-2021

Code answers related to "find the occurances of the letters in the string in python"

Python Answers by Framework

Browse Popular Code Answers by Language