- 3

Somebody can share with me a code to solve Average word lenght exrcise?

Please a need it!!

17th Jul 2020, 8:37 PM
d3ku07
d3ku07 - avatar
19 Respuestas
+ 2
Can you share your attempt so far and explain what you are stuck on?
17th Jul 2020, 8:46 PM
benjamin
+ 1
Look at my edit. The challenge required you to remove punctuation, so I've checked if each char in a word is alphabetic. If it is, I increment a variable and take this value to add to 'chars'. Let me know if you have any questions. https://code.sololearn.com/c32LgSkpjj2n/?ref=app
17th Jul 2020, 10:54 PM
benjamin
0
I don't know if this code is right or not but I need help ! String_words = list(input()) chars = len(String_words) sp_char =["?", ".", "!"] for i in String_words: if i == " ": String_words.remplace(" ", ",") elif i in sp_char: String_words.remplace(i, "") (",").join(String_words) String_words.split(",") num_words = len(String_words) print(int(round(chars / num_words)))
17th Jul 2020, 9:07 PM
d3ku07
d3ku07 - avatar
0
It's give to me some systax mistakes ( sorry but I don't know write english so good !!)
17th Jul 2020, 9:09 PM
d3ku07
d3ku07 - avatar
0
This code does work but it fail in two case! I don't know why! String_words = input().split() words = len(String_words) chars = 0 for i in String_words: chars += len(i) print(round(chars/words))
17th Jul 2020, 10:15 PM
d3ku07
d3ku07 - avatar
0
The first issue is remplace should be replace.
17th Jul 2020, 10:17 PM
benjamin
0
Can you share it from the code playground? Press the + symbol in your reply and press 'Insert code'
17th Jul 2020, 10:18 PM
benjamin
0
How ?😐
17th Jul 2020, 10:19 PM
d3ku07
d3ku07 - avatar
0
Press the + symbol in your reply and press 'Insert code'. Then explain what input you used, what output you got and what output you expected.
17th Jul 2020, 10:22 PM
benjamin
0
I expect to outpout be de average of letter for each word in te string
17th Jul 2020, 10:27 PM
d3ku07
d3ku07 - avatar
0
It seems to work. What input string did you use that didn't work?
17th Jul 2020, 10:28 PM
benjamin
0
Is it a challenge from the app? If so, can you link the challenge?
17th Jul 2020, 10:32 PM
benjamin
0
Yes is a challenge
17th Jul 2020, 10:39 PM
d3ku07
d3ku07 - avatar
0
I don't know if I can link becausa it does not give me the option !
17th Jul 2020, 10:41 PM
d3ku07
d3ku07 - avatar
0
What is the name of the challenge?
17th Jul 2020, 10:43 PM
benjamin
0
Average Word lenght
17th Jul 2020, 11:20 PM
d3ku07
d3ku07 - avatar
0
Length*
17th Jul 2020, 11:23 PM
d3ku07
d3ku07 - avatar
0
YanCrack!!😌 Please see my previous comment. I hope it helps.
17th Jul 2020, 11:30 PM
benjamin