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)
2 RĂ©ponses
+ 2
Meghraj
Use ceil() to round the number.
import math
avg = math.ceil(chars/words)
+ 1
Instead of round use "int()"
Simple