How do I read every line of a file in Python and store each line in a list?
I want to read the file line by line and append each line to a new list.
For example, my file is this:
0,0,2
0,1,3
0,1,5
And I want to achive this :
[0,0,2]
[0,1,3]
[0,1,5]
I tryed with this but isn't given me the answer I wanted.
a_file = open("test.txt", "r")
list_of_lists = [(float(line.strip()).split()) for line in a_file]
a_file.close()
print(list_of_lists)