Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

6. The cost of the training creates a need to show that it works.

Answered: 1 week ago