Cody Bable

Generation

generate functionMon, 03 Jul 2023

count the total number of words in a sentence that occur in the special words list

def count_words(message, special_words): message = message.lower().split() count = 0 for word in message: if word in special_words: count += 1 return count count_words("this is a sentence", ["is", "a"])

Questions about programming?Chat with your personal AI assistant