Python: converting a tuple to a 2D array

I want to convert a tuple as

t = [(4,10),(9,7),(11,2),(2,2)]

into a 2D array, for example:

a = [[4,10],[9,7],[11,2],[2,2]]

I tried

a = []
for i in t:  
    a.append(np.asarray(i))
print a

is there an easier way?

+4
source share
1 answer

Use listas follows:

>>> t = [(4,10),(9,7),(11,2),(2,2)]
>>> [list(item) for item in t]
[[4, 10], [9, 7], [11, 2], [2, 2]]
+5
source

Source: https://habr.com/ru/post/1624674/


All Articles