+ 4

What's wrong in my code could you tell

text = input() word=text.split() count=0 for i in text: if not i=="": count+=1 averge=(count/len(word)) print (averge)

7th Apr 2022, 9:16 AM
Musab Adam
Musab Adam - avatar
6 Answers
+ 5
if not i == " " : edit: you are using empty string instead
7th Apr 2022, 9:22 AM
Jayakrishna 🇼🇳
+ 3
As Jayakrishna🇼🇳 has pointed out, you have not specified a space in your text.
7th Apr 2022, 9:25 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
A space in a text is considered to be a character, so it also gets counted. That is why you must exclude it from your tally
8th Apr 2022, 8:23 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Musab Adam A little code which may help you understand https://code.sololearn.com/cR8q6PcSDb0A/?ref=app
8th Apr 2022, 8:25 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Could you give hint about this reason of this space please
8th Apr 2022, 7:04 AM
Musab Adam
Musab Adam - avatar
0
what is ur aim? u can write it different too...
9th Apr 2022, 5:08 AM
Turan Ediz Saçaklı
Turan Ediz Saçaklı - avatar