outputs avg length ofword in the sentence and rounds it to the next whole no. ........but when I input- Can you not do that? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

outputs avg length ofword in the sentence and rounds it to the next whole no. ........but when I input- Can you not do that?

https://code.sololearn.com/cx5m1TGY28lR/?ref=app It gives wrong output for this input It should be exactly 3 But it comes to be 3.2 And then it rounds it to 4 Plz help finding the bug!!!!

15th Jun 2020, 7:12 AM
Abhijit
Abhijit - avatar
4 Answers
+ 3
Hope it helps you!! you have used isalpha in place of isalpha(). from math import ceil phrase = input() or "Can you not do that?" count = 1 alph = 0 l = len(phrase) for i in range(l) : if phrase[i]==" " : count += 1 elif phrase[i].isalpha() : alph += 1 else : continue avg = ((alph)/(count)) print(phrase) print(ceil(avg))
15th Jun 2020, 7:57 AM
SOUMYA
SOUMYA - avatar
+ 2
from math import ceil phrase = input() count = 1 alph = 0 for i in phrase : if i==" " : count += 1 elif i.isalpha : alph += 1 else : continue avg = ((alph)/(count)) print(ceil(avg)) May This Helps You!
15th Jun 2020, 7:29 AM
Hacker Badshah
Hacker Badshah - avatar
+ 1
thank you ,I didn't noticed that I should'nt have done that .....it's my bad
15th Jun 2020, 8:04 AM
Abhijit
Abhijit - avatar