Cody Bable

Generation

generate functionMon, 03 Jul 2023

check if the word is in the special word of the string, if so, add to dictionary along with count

def find_word(string, word): string_list = string.split() word_dict = {} for i in string_list: if i == word: if i in word_dict: word_dict[i] += 1 else: word_dict[i] = 1 return word_dict find_word("My name is Joy. I like computer science.", "joy")

Questions about programming?Chat with your personal AI assistant