0

Calculating average word length

text = input() sum = 0 for i in text : sum += 1 x = text.split () z = len (x) m = sum / z print (m) Please someone help debug this code for finding average word length

8th Oct 2021, 5:49 PM
Ismael Wesa
9 Respostas
0
Check for the maximum value after you're converting it to the array.
8th Oct 2021, 6:09 PM
zexu knub
zexu knub - avatar
0
Ismael Wesa the problem is that you're counting spaces and punctuation in sum.
8th Oct 2021, 8:18 PM
Simon Sauter
Simon Sauter - avatar
0
Try this: m= x/2 print(m) Instead of: m= sum/2 print (m)
9th Oct 2021, 3:33 AM
Aryan Yadav
Aryan Yadav - avatar
0
Thanks
10th Oct 2021, 6:10 PM
Ismael Wesa
0
Thanks
10th Oct 2021, 6:10 PM
Ismael Wesa
0
Still not working
10th Oct 2021, 6:14 PM
Ismael Wesa
0
10th Oct 2021, 6:18 PM
Simon Sauter
Simon Sauter - avatar
0
Aryan Yadav that's wrong. In several ways.
10th Oct 2021, 6:19 PM
Simon Sauter
Simon Sauter - avatar
0
Ok
11th Oct 2021, 9:42 AM
Ismael Wesa