Question: Suppose you have a function that is given a string and a letter, and returns the number of times the letter occurs in the string:

Suppose you have a function that is given a string and a letter, and returns the number of times the letter occurs in the string: def countchar (str, ch): return count Write a new function called allwords that takes a list of strings as parameters, and returns a list containing number of times the given character appears in each of the words. For example, the following function call: allwords (['abracadabra', 'magic', 'wand', 'mystery'), 'a') would return the list: [5, 1, 1, 0] because the letter 'a' appears 5 times in 'abracadabra', 1 time in 'magic' and 'wand' and 0 times in 'mystery! NOTE: You are not asked to write the countchar function. The function you write should CALL the countchar function to do its job
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
