Question: PROBLEMS 1. Write a function called countLetters() that accepts a list of strings as the first argument, and a string that is one character long
PROBLEMS 1. Write a function called countLetters() that accepts a list of strings as the first argument, and a string that is one character long as the second argument. The funtion should PRINT (not return) the number of times that the character is present in the list of strings. However, your function should NOT care about case. So if the user is wants to count the number of 'e' letters in the list of strings, your function should count 'e' as well as 'E'. HINT: One way might be to convert all of the strings in the list to upper case. Then convert the character to search for to upper case as well. Once you've done that, you can count the number of times it appears. When your function prints the results, you should use a format string so that the outputted statement says something like: "The letter C appears 3 times." Examples: sports = ['Baseball', 'Soccer', 'HOCKEY', 'table tennis', 'Quidditch'] countLetters (sports, 'b') #Should print: The letter B appears 3 times. countLetters (sports, 'C') #Should print: The letter Cappears 4 times
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
