I am trying to print two lines of text from a text file in python which are next to eachother on a separate line. So the text file looks like this:
Apples
Oranges
Pears
Lemons
And if someone inputs Apples I would like the program to print out:
Apples
Oranges
Here is the code I have so far:
file = open('Fruit.txt',"r")
for line in file:
if InputText in line:
print(line)
print(line+1)
return
file.close()
Of course the variable line+1 isn't correct but I have left it there to illustrate that the next line of text must also be printed.