+ 1

How i solve Average word length problem

This is my Code ,test case 1,2,4 are correct,what is the problem I can't find , input=input('') input=input.split(' ') wordlist=0 for i in range(len(input)): #print(len(input[i])) wordlist += len(input[i]) average=int(round(wordlist/len(input))) print(average)

27th Oct 2020, 10:23 AM
Ruhul Amin
Ruhul Amin - avatar
3 Answers
+ 5
Ruhul Amin , to help you we need to get the complete task description that is shown in this code coach task. Thanks!
27th Oct 2020, 11:09 AM
Lothar
Lothar - avatar
0
Not sure but I think '?' and '.' are not counted as words' characters. Remove every '?' and '.' in the input then check if your code works fine.
27th Oct 2020, 10:32 AM
Soheil
Soheil - avatar
0
Another mistake you've made is that you are rounding the answer down OR up (in some cases up and in some other cases down). You have to round it up in every case (use math.ceil).
27th Oct 2020, 10:41 AM
Soheil
Soheil - avatar