generate functionMon, 20 Mar 2023

On the first line, one character is entered - a lowercase letter. The sentence is entered on the second line. Output It is necessary to output a list of words (a word is a part of a sentence surrounded by white space characters) in which the entered letter is present in any case, in the same order in which they occur in the sentence.

def looking4letters(letter, sentence): return [word for word in sentence if letter.lower() in word.lower()] looking4letters('h', 'Hello world') looking4letters('h', 'Hello world') looking4letters('s', 'She sells sea shells on the sea shore') looking4letters('a', 'An apple a day keeps the doctor away')

Questions about programming?Chat with your personal AI assistant