My txt file looks like this:
[[1,3,5],[1,4,4]]
[[1,4,7],[1,4,8],[2,4,5]]
And I was trying to convert it into a list, which include all the lists in the txt file. So the desired output for my example would be:
[[[1,3,5],[1,4,4]], [[1,4,7],[1,4,8],[2,4,5]]]
It seems like an easy task, except that I could only get this:
['[[1,3,5],[1,4,4]]', '[[1,4,7],[1,4,8],[2,4,5]]']
Is there an easy way to convert the string type into a list?
The code I used :
input_list = []
with open("./the_file.txt", 'r') as f:
lines = f.read().split('\n')
for each_line in lines:
input_list.append(each_line)
f.close()