Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

At the end of textbooks, there usually is an index that lists the pages where ce

ID: 3547247 • Letter: A

Question

                            At the end of textbooks, there usually is an index that lists the pages where certain words appear. In this problem, you will create an index for a                             text but, instead of page number, you will use the line numbers.                         

                        

                            
                        

                        

                            You will implement function index() that takes as input the names of a text file and list of words. For every word in the list, your function will find                             the lines in the text file where the word occurs and print the corresponding line numbers/9where the numbering stats at 1). You should open and read                             the fiel only once.                         

                        

                            
                        

                        

                            >>>index('raven.txt',['raven', 'mortal', 'dying', 'ghost', 'ghastly', 'evil', 'demon'])                         

                        

                            ghost 9
                        

                        

                            dying 9                         

                        

                            demon 122                         

                        

                            evil 99,106                         

                        

                            ghastly 82                         

                        

                            mortal 30                         

                                                     raven 44,53,55,64,78,104,111,118,120

Explanation / Answer

raven 44,53,55,64,78,104,111,118,120