Convert tuple and string to list

For this particular situation, you can use eval.

>>> n = (102, '(24, -20)') 
>>> n = list(n)
>>> n
[102, '(24, -20)']
>>> n[1] = eval(n[1])
>>> n
[102, (24, -20)]
>>> new = (n[0], [1][0], n[1][1])
>>> new
(102, 1, -20)

Browse More Popular Posts

Leave a Comment