0

Can anyone send me average word length solution in python I have doing in this code all case are done but case1 notdone

word=str(input()) length=len(word) count=0 for lund in word: if(lund==" "): count+=1 count=count+1 print(length//count)

24th Mar 2021, 2:08 PM
MAVADIYA DIVYESHKUMAR
MAVADIYA DIVYESHKUMAR - avatar
3 odpowiedzi
+ 3
input get you a sentence (list of word separated by spaces). you need to split() this sentence into a list of words, then you must sum all words length and finally print the average by doing sum_word_length/words_count... alternativaly, you could get the sum_word_length by counting char ('lund') wich are NOT spaces... or compute it as sentence_length-spaces_count ;)
24th Mar 2021, 2:22 PM
visph
visph - avatar
+ 1
Thanks bro
24th Mar 2021, 2:26 PM
MAVADIYA DIVYESHKUMAR
MAVADIYA DIVYESHKUMAR - avatar
+ 1
try this from math import ceil txt = input().split() not_char = [".",",","?"] num_char = 0 for word in txt: for char in word: if char in not_char: continue num_char += 1 avg = num_char / len(txt) print (ceil(avg))
22nd Apr 2021, 9:07 AM
Ahmed Azami Hassani
Ahmed Azami Hassani - avatar