I want my simple python program to go to a text file and collect 5 lines to print out.
I have got this far but it returns the whole file which I don't want to do yet.
file=open('IH.txt','r')
text = file.read()
print(text)
file.close()
Can anyone help?
returnand increment the counter variable by one. In case the counter reaches 5 do return.https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files