DeadMarshall / codecademy

codecademy courses
0 stars 0 forks source link

Wrong function #1

Closed sen1 closed 6 years ago

sen1 commented 6 years ago

https://github.com/DeadMarshall/codecademy/blob/6f67a46034f5b5584c9f0e26fd028b57f73e80b6/bstinsonMurder%2BMystery.py#L61-L73

You are supposed to count the words in the sentence. So you have a words_in_text with all the words in the sentence. Then you loop over the words one by one. The second loop on line 71 actually loops over the letters in the words. This is wrong implementation.

Once you get the sentences, here is the right way to implement it:

    sentence_lengths = []
    for sentence in sentences:
        words = sentence.split()
        sentence_lengths.append(len(words))

    average = sum(sentence_lengths) / len(sentence_lengths)
    return average
DeadMarshall commented 6 years ago

fixed