Question: How do I go about getting my code to count only letters or is my word count also wrong? AverageWordLength.py 21 #In this problem, you
AverageWordLength.py 21 #In this problem, you should write three functions: 3: #word-count, letter-count, and average-word-length. S tword count should take as input a string. It should return 6.#the number of words in the string. You may assume that the 7#number of words in the string will be one more than the 8: number of spaces in the string. , 9: # 18 #letter-count should take as input a string. It should return 11i#the number of letters in the string. You may assume that rthe string is only letters and spaes: no punctuation or 13: #numbers. 14| # 15 #average word length, should take as input a string. It should 16#return the average length of the words in the string. You 17#can find the average length by dividing the number of letters 18 tby the number of words. 19 28 tYour implementation for average word length "must call tword count and letter count. 23 24 #Add your code here! def average word lengthfstring): 26 number lettersletter count(string) number words word count (string) avg-len number-letters) return avg len number-words 30, def word-countstring): 31count1 32for a in string: 34 35 36 def letter count(string): count += 1 return count count . 38 for a in string: for 3in string; 40 41 42 43 count 1 else: count += 1 eturn count Previous: Next
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
