+ 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 Answers
+ 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