def count_word_occurrences(string, word):count = 0words = string.split()for w in words:if w == word:count += 1return count
string = "Python is a popular programming language. Python is used for web development and data analysis."word = "Python"
result = count_word_occurrences(string, word)print(f"The word '{word}' occurs {result} times in the string.")
def count_word_occurrences(string, word):
count = 0
words = string.split()
for w in words:
if w == word:
count += 1
return count
string = "Python is a popular programming language. Python is used for web development and data analysis."
word = "Python"
result = count_word_occurrences(string, word)
print(f"The word '{word}' occurs {result} times in the string.")