def word_search(doc_list, keyword): """ Takes a list of documents (each document is a string) and a keyword. Returns list of the index values into the original list for all documents containing the keyword. Example: doc_list = ["The Learn Python Challenge Casino.", "They bought a car", "Casinoville"] >>> word_search(doc_list, 'casino') >>> [0] """ indices = [] for i, doc in enumerate(doc_list): tokens = doc.split() normalized = [token.rstrip('.,').lower() for token in tokens] if keyword.lower() in normalized: indices.append(i) return indices """ if we didn't remove . and , the result could be different lowerKey = keyword.lower() result = [] for i in range(len(doc_list)): EachWords = doc_list[i].lower().split() for eachword in EachWords: #print lowerKey if lowerKey in eachword: result.append(i) return result """ doc_list = ["The Learn Python Challenge Casino.", "They bought a car", "Casinoville"] print(word_search(doc_list, 'casino'))