Question: what am I doing wrong here? And what do I replace to fix it? 1 point 7. Use a dictionary to count the frequency of

what am I doing wrong here? And what do I replace to fix it?
1 point 7. Use a dictionary to count the frequency of letters in the input string. Only letters should be counted, not blank spaces, numbers, or punctuation. Upper case should be considered the same as lower case. For example, count_letters("This is a sentence.") should return {'t': 2, 'h': 1, '': 2, 's': 3, 'a': 1, 'e': 3, 'n': 2, 'c': 1}. 1 Z 3 4 5 6 7 8 def count_letters (text): result = 3 # Go through each letter in the text for letter in text. Lower: # Check if the letter needs to be counted or not if letter. isalpha() and letter not in: result: result[letter]= text. Lower().count(letter) #Add or increment the value in the dictionary return result print(count_letters("AaBbcc")) # Should be {'a': 2, 'b': 2, 'c': 2} 9 10 11 12 13 14 15 16 17 18 19 print(count_letters ("Math is fun! 2+2=4")) # Should be 'm': 1, 'a': 1, 't': 1, 'h': 1, 'i': 1, 's': 1, 'f': 1, 'u': 1, 'n': 1} Run print(count_letters("This is a sentence.")) # Should be {'t': 2, 'h': 1, 'i': 2, 's': 3, 'a': 1, 'e': 3, 'n': 2, 'c': 1} Reset Error on line 6: if letter. isalpha and letter not in: A SyntaxError: invalid syntax
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
