I’m writing a huge code and one of the little things I need it to do is go over a text file that is divided to different lines.
i need it to create a new list of lines every time the line is empty. for example if the text is: (each number is a new line)
1
2
3
4
5
6
3
1
2
it should build 3 different lists: [1,2,3,4], [5,6,3], [1,2]
this is my code so far (just getting started):
new_list=[] my_list=[] doc=open(filename, "r") for line in doc: line=line.rstrip() if line !="": new_list.append(line) return new_list
Ok, This should work now: