Av word length | Sololearn: Learn to code for FREE!

0

Av word length

text =input() count =text.split() count = 0 sum = 0 for x in text: sum += len(x) count += 1 Av = int(sum)/count print(Av)

5/30/2021 7:31:01 AM

Harsh Jain

9 Answers

New Answer

+2

count = text.split() should be: text = text.split()

+1

Done it's running TQ

0

what is your question/problem? I guess that your code doesn't work, because you are assigning the word list to 'count' variable instead of 'text' ;P

0

I din understand I am still in python data structure

0

The output is always 1

0

Given a sentence as input, calculate and output the average word length of that sentence. To calculate the average word length, you need to divide the sum of all word lengths by the number of words in the sentence. Sample Input: this is some text Sample Output: 3.5 Explanation: There are 4 words in the given input, with a total of 14 letters, so the average length will be: 14/4 = 3.5

0

read again my post: I explained why ^^

0

So what shld I replace the word count

0