I know to split a file by lines, you can do f.readlines()
, but what if I was trying to split a file by every n lines? For example, I have a file
line1
line2
line3
line4
line5
line6
line7
line8
instead of looping through it line by line, I want to loop through it by every two lines, so it would output
line1
line2
line3
line4
etc