+ 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
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()
+ 7
len(text) counts spaces and punctuation marks as letters.
0
Simon Sauter thanks
0
Simon Sauter but its not still working
0
Lothar thanks but please can you give me an example with some line of code