How do I solve case 2 | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

How do I solve case 2

def average_word_length(sentence): words = sentence.split() return sum(len(word) for word in words) / len(words) sentence = "sololearn is awesome" print(average_word_length(sentence))

24th Apr 2023, 2:34 PM
ARBEIT MANN
ARBEIT MANN - avatar
5 Respuestas
+ 4
"sentence" is an input value, not a fixed value
24th Apr 2023, 2:49 PM
Lisa
Lisa - avatar
+ 4
TENGRANN SAN , there are some issues to fix in the code. may be you have overseen some details in the task description: > input has to be done like: sentence = input() > all *punctuation* in the input text has to be removed. > the output value has to be *rounded up* to the nearest whole number. after this corrections the code should run properly.
25th Apr 2023, 4:43 PM
Lothar
Lothar - avatar
+ 1
It's the same problem as in here: https://www.sololearn.com/discuss/3208736/?ref=app You set a fixed value to variable sentence. So the code output will be fixed too, instead of processing the test cases. Pls redo the lesson on user input.
24th Apr 2023, 11:31 PM
Emerson Prado
Emerson Prado - avatar
0
Test case two is supposed to have an average of 4.7
24th Apr 2023, 2:34 PM
ARBEIT MANN
ARBEIT MANN - avatar
0
Still dont understand
24th Apr 2023, 8:00 PM
ARBEIT MANN
ARBEIT MANN - avatar