+ 1

Average Word length code coach. Failed test case 5. Why failed? Explained for me?

import math text = input() wordLength = text.count(' ') + 1 letterLength = len(text) - wordLength print(math.ceil(letterLength / wordLength))

25th Apr 2020, 3:32 PM
Purevsuren
Purevsuren - avatar
4 odpowiedzi
+ 2
letterLength is not len(text) - wordLength because you have +1 in your wordLength calculation.
25th Apr 2020, 4:19 PM
Gordon
Gordon - avatar
+ 1
you should calculate each word length first, and then calculate the average
25th Apr 2020, 3:44 PM
Gordon
Gordon - avatar
0
thanks, but very general answer
25th Apr 2020, 4:08 PM
Purevsuren
Purevsuren - avatar
0
could you my code review, and then explain my fault?
25th Apr 2020, 4:08 PM
Purevsuren
Purevsuren - avatar