-1

I have seen some similar questions but it is not exactly what Im looking for. I have

["[1, 2, 3],[4, 5, 6],"]

which is the output of a file and Im wondering how to convert it to

[[1,2,3],[4,5,6]]

pd: it is only possible to use built-in python functions(except for eval), no external libraries allowed Thanks in advance

Franco
  • 5
  • 6

1 Answers1

2

ast.literal_eval safely evaluates the argument

import ast
l= ['[1, 2, 3],[4, 5, 6],']
l[0]=list(ast.literal_eval(l[0]))