Question: 2. (15 points) Write a recursive function recWordCount0 that takes an arbitrarily nested list as a parameter and returns the number of occurrences of a
2. (15 points) Write a recursive function recWordCount0 that takes an arbitrarily nested list as a parameter and returns the number of occurrences of a word found in the strings in the list. The word is passed in as a parameter and case should be ignored. Recall that you can determine whether an item is an string writing type(item) str and whether an item is a list by writing type(item)list. The function should not use any loops. The only list functions you are allowed to use are len0, indexing (lst[i] for an integer i), or slicing (Ist i j] for integers i and j). The following shows several sample runs of the completed function: >>> print (recWordCount (I),'a)) 0 >> print (recword Count (11, 'a ,3,4,5),a)) >>print (recWordcount CLEELi1,'test test'1,3]11, 0'test',5.0, 'test test']11, 't est'))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
