Write a Python program which allows you to extract the content of a file from the
3rd line to the 5th line and save it in another file.
file1 = 'input.txt'
infile = open(file1, 'r')
file2 = 'output.txt'
outfile = open(file2, 'w')
count=0;
for line in infile:
count+=1
if(count>=3 and count<=5):
outfile.write(line)
infile.close()
outfile.close()
Comments
Leave a comment