The problem is very fundamental. All I want to know is if there is a function to perform the task without appending to a new list.
I tried using loop but it will become a little complex for cases like... '[1,2,3],[4,5,6]'
The problem is very fundamental. All I want to know is if there is a function to perform the task without appending to a new list.
I tried using loop but it will become a little complex for cases like... '[1,2,3],[4,5,6]'
The simple way:
import re
regex = re.compile("'|\[|\]")
new_list = re.sub(regex, "", '[1,2,3],[4,5,6]')
I'm sure that you can find a wiser way.
In [1]: a = '[1,2,3],[4,5,6]'
In [2]: import ast
In [3]: ast.literal_eval(a)
Out[3]: ([1, 2, 3], [4, 5, 6])
For ref : ast