- 3
Somebody can share with me a code to solve Average word lenght exrcise?
Please a need it!!
19 Answers
+ 2
Can you share your attempt so far and explain what you are stuck on?
+ 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
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)))
0
It's give to me some systax mistakes ( sorry but I don't know write english so good !!)
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))
0
The first issue is remplace should be replace.
0
Can you share it from the code playground? Press the + symbol in your reply and press 'Insert code'
0
How ?😐
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.
0
I expect to outpout be de average of letter for each word in te string
0
It seems to work. What input string did you use that didn't work?
0
Is it a challenge from the app? If so, can you link the challenge?
0
Yes is a challenge
0
I don't know if I can link becausa it does not give me the option !
0
What is the name of the challenge?
0
Average Word lenght
0
Length*
0
YanCrack!!😌 Please see my previous comment. I hope it helps.