What's wrong with my code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's wrong with my code?

I try to solve average world lenght problem. I got 4/5. I just wrong at test 1. I count it manually and get 3,..... If it rounded up, its must be 4. Why the true output is 3? This is my code x = input() y = x.split(" ") n = int(len(y)) sum = 0 for i in y: a = len(i) sum = sum + int(a) print((sum//n)+1)

24th Oct 2020, 12:52 PM
Haposan Delon Benyamin Pasaribu
2 Answers
0
A word may contain a punctuation, it doesn't count into the length of that word. For instance, the word 'abc.;,' has a length of 3 not 6.
24th Oct 2020, 12:58 PM
QTWizard
0
Thanks a lot, i will try again
24th Oct 2020, 1:01 PM
Haposan Delon Benyamin Pasaribu