0

How do I find the number of word that will be input. Please give me hints. And Thank You

https://code.sololearn.com/cbde9YBVNs0i/?ref=app

21st May 2023, 3:28 AM
Kyaw Hok
Kyaw Hok - avatar
10 ответов
+ 5
Kyaw Hok Then your code is incomplete. Read the description properly given in the code coach
21st May 2023, 4:56 AM
Hasnain [ACTIVE CHALLENGER]
Hasnain [ACTIVE CHALLENGER] - avatar
+ 5
You can try different strategies to calculate this. First, splitting the input to a list of words is a good start. The average length is the total number of characters in all words (excluding whitespaces) divided by the number of words. You can write a loop to sum the number of characters of each word. You could also check the size of the original input (but remember that it has the extra whitespaces). Read carefully in the task, what is the expected data type of the output: whole number (int) or a decimal (float) with a certain precision rounded. Remember Python has two division operators / and //
21st May 2023, 5:00 AM
Tibor Santa
Tibor Santa - avatar
+ 3
Kyaw Hok Your code already does it. What's the difficulty?
21st May 2023, 3:55 AM
Emerson Prado
Emerson Prado - avatar
+ 3
You had not used print statement. Use it to get output
21st May 2023, 4:44 AM
Hasnain [ACTIVE CHALLENGER]
Hasnain [ACTIVE CHALLENGER] - avatar
+ 3
Kyaw Hok Pls note your question is misleading. You don't have to "find the number of word" - indeed, your code already does it. Pls edit your question description properly. That said, Tibor Santa 's answer has all you need.
21st May 2023, 9:56 PM
Emerson Prado
Emerson Prado - avatar
+ 1
Just add print (length) in the code. Res everything is fine.
22nd May 2023, 3:28 PM
Vibhor
Vibhor - avatar
+ 1
You can check this also: Another method https://code.sololearn.com/c45cQtYNnSzp/?ref=app
22nd May 2023, 3:35 PM
Vibhor
Vibhor - avatar
+ 1
Yashar Zavary I think you didn't understand the task. Pls read again.
23rd May 2023, 12:47 AM
Emerson Prado
Emerson Prado - avatar
0
I have to output the average word length but my output does not match with the output of the result.
21st May 2023, 4:52 AM
Kyaw Hok
Kyaw Hok - avatar
0
your code is ok but you have one problem when you split one string it will make a list of strings that is splitted by space... you must say x=input() print(len(x)) and finish!
22nd May 2023, 10:21 PM
Yashar Zavary
Yashar Zavary - avatar