How can I convert \"[(5, 2), (1,3), (4,5)]\" into a list of tuples
[(5, 2), (1,3), (4,5)]
I am using planetlab shell that doe
'join' replace following characters '()[] ' and creates string of comma separated numbers
5,2,1,3,4,5
'split' splits that string on ',' and creates list strings
['5','2','1','3','4','5']
'iter' creates iterator that will go over list of elements
and the last line uses a list comprehension using 'zip' to group together two numbers
it = iter("".join(c for c in data if c not in "()[] ").split(","))
result = [(int(x), int(y)) for x, y in zip(it, it)]
>>> [(5, 2), (1, 3), (4, 5)]