+ 2

Average Word Length

Please whats wrong with my code text = input() letter = len(text) word = len(text.split()) average = letter/word print(average) I will appreciate you all effort

31st Dec 2021, 7:29 PM
Cyber DeCypher 🐎
Cyber DeCypher 🐎 - avatar
5 Réponses
+ 8
Destiny Simon , Simon Sauter , if we are talking about *python for datastructures* code coach exercise no. 13: we do not need to remove punctuation, this is (no longer) mentioned in the task description we can use this: ▪︎take input string ▪︎split input string (this will result in getting a list that we name *word*) ▪︎use string method replace(...) to remove all spaces from variable *text* ▪︎get length of variable text (=number of characters without spaces) ▪︎calculate letter/ word ▪︎output result using print()
1st Jan 2022, 12:27 PM
Lothar
Lothar - avatar
+ 7
len(text) counts spaces and punctuation marks as letters.
31st Dec 2021, 7:53 PM
Simon Sauter
Simon Sauter - avatar
0
1st Jan 2022, 8:24 AM
Cyber DeCypher 🐎
Cyber DeCypher 🐎 - avatar
0
Simon Sauter but its not still working
1st Jan 2022, 8:26 AM
Cyber DeCypher 🐎
Cyber DeCypher 🐎 - avatar
0
Lothar thanks but please can you give me an example with some line of code
3rd Jan 2022, 1:33 AM
Cyber DeCypher 🐎
Cyber DeCypher 🐎 - avatar