+ 1
Average word length: python
I think there is something wrong with the test case We need to find average length of words in sentence, removing punctuation. For the sentence: 'The longest word in the dictionary is...' No of letters is: 31 No. Of words: 7 Then average will be 4.4 If round off, then 4 And thats the output of my code, but the expected output is 5. Please correct me if i m going wrong https://sololearn.com/compiler-playground/cabF63QU6OO4/?ref=app
4 Respostas
+ 6
The specific task in the code challenge section asks you to "round up to the next integer".
Use the ceil() function instead of round() and your code will be fine.
+ 4
Tibor Santa Yeah, it worked! Thank you 😊
+ 2
Wilbur Jaywright I couldnt think of any other way, I need to work on my problem solving skills,
And yeah, i knew that True will be returned, but wasn't sure, thanks for mentioning 😊
+ 1
I feel like this code is unneccesarily complicated by counting letters in individual words one at a time when it could be counting them from the whole sentence at once. Remove that, and maybe you’ll see the problem.
Side note, there is no reason to ever use “== True” in your code. True is already the output of a test condition, so it’s completely redundant.