0

average word length code coach problem

here is my code. I am getting 3/5 test cases right. Hidden test cases are wrong. Can someone please help me spot the bug? text = input() #string words=0 chars=0 for x in list(text): if x not in " @#$_&-+*:;!?,\/": chars+=1 text = text.split() #print(text) words = len(text) avg = round(chars/words) print(avg)

26th May 2021, 10:00 AM
Meghraj
Meghraj - avatar
2 ответов
+ 2
Meghraj Use ceil() to round the number. import math avg = math.ceil(chars/words)
26th May 2021, 10:17 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar
+ 1
Instead of round use "int()" Simple
26th May 2021, 10:43 AM
Yash Wable 🇮🇳
Yash Wable 🇮🇳 - avatar