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.

11th Jan 2023, 9:43 AM
chess doctor
chess doctor - avatar
5 Respuestas
+ 3
It might be the issue with your code so you need to see description again and change the logic accordingly.
11th Jan 2023, 10:04 AM
A͢J
A͢J - avatar
+ 2
Yea you’re right … thanks jayakrishna
11th Jan 2023, 11:33 AM
chess doctor
chess doctor - avatar
+ 1
chess doctor "Remove all punctuation". You are missing this.. The input has '?' . You should not calculate it as character in word length.
11th Jan 2023, 10:20 AM
Jayakrishna 🇮🇳
0
I didnt miss it actually. Rest of the test cases also have punctuations in them and they work with the code
11th Jan 2023, 10:30 AM
chess doctor
chess doctor - avatar
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)
11th Jan 2023, 11:18 AM
Jayakrishna 🇮🇳