Can you help me find out mistake To calculate the average length of words in string and rounding it up to the nearest whole num. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you help me find out mistake To calculate the average length of words in string and rounding it up to the nearest whole num.

# My code: str = input() strlist = str.split() sum = 0 count = 0 for word in strlist: length = len(word) sum += length count += 1 avg = sum / count print(round(avg)) 3rd and 5th test cases failed when I run this code..

20th Oct 2020, 4:01 PM
CHAKKA VENKATA NAGA SAI JYOTHIRMAI
CHAKKA VENKATA NAGA SAI JYOTHIRMAI - avatar
1 Answer
+ 2
Average word length code coach : In this question they told that "Remove all punctuation" ,I didn't see any code for removing punctuation .
20th Oct 2020, 4:06 PM
The future is now thanks to science
The future is now thanks to science - avatar