Reference no: EM132355571
Question
Write the recursive function containing_word, which takes as its argument a nested list of sentence strings and a target word, returning a list of sentences that contain the target word.
• The function should ignore objects of types other than list or string. Assume that if the function encounters a string, that the string is guaranteed to be a sentence.
• Any sentence will be a string of words separated by any number of spaces, with no other characters (i.e. no punctuation - no periods, commas, etc).
• For this function, uppercase words are considered distinct from lowercase words. o Example: "Excellent" is not considered the same as "excellent" It should ignore objects of types other than list or string.
For example, consider the list defined below:
sentence_list = ['I am Boo', ['I wear Boots', ['Boo is love'], 'Nothing here']]
The call containing_word(sentence_list, 'Boo') should return ['I am Boo', 'Boo is love']
def containing_word(slist: [str or list], target: str) -> [str]