+ 9

What is the problem in my code

Average word length problem a=input() list=a.split(" ") b=a.replace(" ","") c=(len(b)/len(list)) print(round(c))

11th Jan 2022, 6:58 PM
Atul Bangre
Atul Bangre - avatar
7 Answers
+ 9
1. Good logic!!! OMGable! 2. don't use built in function names! Instead use lst or l 3. Try to this: c = len(b)/len(list) result = round(c, 2)
11th Jan 2022, 7:43 PM
Shadoff
Shadoff - avatar
+ 9
Works like a charm
11th Jan 2022, 7:38 PM
Oma Falk
Oma Falk - avatar
+ 1
My code show error in some test cases in sololearn avrage word length problem
12th Jan 2022, 5:17 PM
Atul Bangre
Atul Bangre - avatar
+ 1
if c>int(c): c=int(c)+1 Add this code before print It actually works
12th Jan 2022, 5:30 PM
Saydimurod Qodirjonov
Saydimurod Qodirjonov - avatar
+ 1
In case of 15/5 my code showe 4 and expectad coutput is 3
12th Jan 2022, 6:12 PM
Atul Bangre
Atul Bangre - avatar
+ 1
I solved this program And here is my code: s=input() s1='' s2=s.split() for i in s: if i in 'abcdefghijklmnopqrstuvwxyz': s1+=i l=len(s1)/len(s2) if l>int(l): l=int(l)+1 print(l)
12th Jan 2022, 8:11 PM
Saydimurod Qodirjonov
Saydimurod Qodirjonov - avatar
0
But your code works What did you want? What problem did you want to solve?
12th Jan 2022, 4:44 PM
Saydimurod Qodirjonov
Saydimurod Qodirjonov - avatar