Cody Bable

Generation

generate functionMon, 03 Jul 2023

check if the word in the string is in the list of the special words to count, if so, add to dictionary along with the number of times it occurred in the string. if the special word is not in the string, return the special word with zero.

def count_special_words(word, sentence): count = 0 for letter in sentence: if letter == word: count += 1 return count count_special_words("f", "ff")

Questions about programming?Chat with your personal AI assistant