0
How do I find the number of word that will be input. Please give me hints. And Thank You
10 Answers
+ 5
Kyaw Hok
Then your code is incomplete. Read the description properly given in the code coach
+ 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 //
+ 3
Kyaw Hok Your code already does it. What's the difficulty?
+ 3
You had not used print statement. Use it to get output
+ 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.
+ 1
Just add print (length) in the code.
Res everything is fine.
+ 1
You can check this also:
Another method
https://code.sololearn.com/c45cQtYNnSzp/?ref=app
+ 1
Yashar Zavary I think you didn't understand the task. Pls read again.
0
I have to output the average word length but my output does not match with the output of the result.
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!