+ 1

Average word length not accepting solution

import math sentence = input () lengths = 0 amount = 0 for word in sentence. split(' '): lengths += len(word) amount+=1 print(math.ceil(lengths / amount)) The example turns 5.2 into six, so it *has* to use ceil right? Why is this code not accepted? :S

17th Oct 2020, 7:59 AM
Tjipke van der Heide
Tjipke van der Heide - avatar
3 Réponses
+ 1
From the description: "Remove all punctuation".
17th Oct 2020, 8:15 AM
Russ
Russ - avatar
+ 2
BTW you don't need to say sentence.split(' ') because ' ' is the default split character. Just say sentence.split() 🙂
17th Oct 2020, 8:26 AM
David Ashton
David Ashton - avatar
+ 2
Thank you! I must have not read the part where punctuation needed removing ^^ that was it!
17th Oct 2020, 8:37 AM
Tjipke van der Heide
Tjipke van der Heide - avatar