generate functionMon, 20 Feb 2023

A list of texts is given, the words in which are separated by spaces (we can assume that there are no punctuation marks). Some of the words are "garbage": they contain numbers and special characters. Filter out such words from each text. Use the str.split, str.isalpha, str.join functions, as well as the filter generator. sentences = ['1 thousand devils', 'My name is 9Pasha', 'Room #125 costs $100'] def process(sentences): #YOUR CODE result = #YOUR CODE return result assert process(sentences) == ['thousand devils', 'My name is', 'Room costs'], \ "Something is wrong! Please try again"

sentences = ['1 thousand devils', 'My name is 9Pasha', 'Room #125 costs $100'] def process(sentences): #YOUR CODE res = [] for sentence in sentences: res.append(' '.join(list(filter(lambda word: word.isalpha(), sentence.split())))) return res assert process(sentences) == ['thousand devils', 'My name is', 'Room costs'], \ "Something is wrong! Please try again" process(sentences)

Questions about programming?Chat with your personal AI assistant