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

PYTHON: At the end of this and other textbooks, there usually is an index that l

ID: 3675079 • Letter: P

Question

PYTHON:

At the end of this and other textbooks, there usually is an index that lists the pages where a certain word appears. 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 name of a text file and a 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 (where the numbering starts at I). You should open and read the file only once.

Explanation / Answer

indexing.py

sample output:

I have created a file named raven.txt and got this output

you can use your own raven.txt and word of list

ghost : 2
mortal :
grave : 6
dead : 3,6
raven : 4,5