Open ad3429 opened 6 years ago
The way you wrote the function seems fine, but another way to write it as the hint suggests is by using .replace() such as:
def get_average_sentence_length(text): no_questions = text.replace('?', '.') no_exclaim = no_questions.replace('!', '.') sentences = no_exclaim.split('.') sentence_lengths = [] for sentence in sentences: words = sentence.split() sentence_lengths.append(len(words)) average = sum(sentence_lengths) / len(sentence_lengths) return average
The way you wrote the function seems fine, but another way to write it as the hint suggests is by using .replace() such as: