0
Problem in code coach
a=input() a=a.split(" ") s=0 for i in a: s+=len(i) avg=s/len(a) if avg<=round(avg): print(round(avg)) else: print(round(avg)+1) This is the code for average word length. It is the problem statement in âmediumâ catagory of code coach in community section. The issue is that after running this code all test cases except âtest case 1â are right. âTest case 1â shows wrong answer in the app. Mods please change the answer with the right one.
5 Answers
+ 3
It might be the issue with your code so you need to see description again and change the logic accordingly.
+ 2
Yea youâre right ⌠thanks jayakrishna
+ 1
chess doctor
"Remove all punctuation".
You are missing this.. The input has '?' . You should not calculate it as character in word length.
0
I didnt miss it actually. Rest of the test cases also have punctuations in them and they work with the code
0
May be you are fortunate there.
See 2nd example has 3 dots. You should remove.
With dots 31/7=4.4..=> 5 ( rounded up)
Without dots 34/7=4.8..=> 5 ( rounded)
So output is same. But 1st test case. With punctuation, output is 4. (wrong.)
Without punctuation, output is 3. (correct)