I am new to python and am trying to create a function in python that finds the lines where the word occurs in a text file and prints the line numbers. The function takes the text file name and list of words as input. I don't know where to start.
Example
index("notes.txt",["isotope","proton","electron","neutron"])
isotope 1
proton 3
electron 2
neutron 5
This is some random code that I made with text; so, I don't know if it can help me or not.
def index():
infile=open("test.txt", "r")
content=infile.read()
print(content)
infile.close()
The goal is to be able to find the words in the text file like a person would find a word in the index of a book.