I have a txt file in below format and i want to split this file in such a way that it split the file after 4th line in one list list.
Input file:
1 A
2 B
3 C
4 D
5 A
6 B
7 C
8 D
9 A
10 B
11 C
12 D
i.e. I need the output in this format of lines [A B C D, A B C D, A B C D]
I tried below code but its not helping me out
f = open("demoFile.txt", "r")
for line in f:
with open("demoFile.txt", 'r') as infile:
lines = [line for line in infile][:4]
print(lines)