I just started playing around with python. I know that we can convert any list to a string using str() Like:
>>> l = [[1,1] , [2,2] , [3,3]]
>>> l
[[1, 1], [2, 2], [3, 3]]
>>> type(l)
<type 'list'>
>>> str(l)
'[[1, 1], [2, 2], [3, 3]]'
>>> list_string = str(l)
>>> list_string
'[[1, 1], [2, 2], [3, 3]]'
>>> type(list_string)
<type 'str'>
Is there a way to convert list_string back to a 2d list ?? Basically, is there a function to convert this back to its original form ?
old_list = magic_conversion_func(list_string)
>>>old_list
[[1, 1], [2, 2], [3, 3]]
I tried list() but that converts every char in the string to a new list element.
>>> list(list_string)
['[', '[', '1', ',', ' ', '1', ']', ',', ' ', '[', '2', ',', ' ', '2', ']', ',', ' ', '[', '3', ',', ' ', '3', ']', ']']
that is not what I want