0

A complicated tuple generated by sqlite3. Like this:

[('1', '2', '3')]

How can I convert a tuple into a list like with this output:

[('1',), ('2',), ('3',)]

to

['1', '2', '3']

?

list(arr) does not work, sum(list(arr), []) does not work either.

Jubin Justifies
  • 397
  • 4
  • 12

3 Answers3

2

you can use this:

a = [('1',), ('2',), ('3',)]

[''.join(i) for i in a]

Yeganeh Salami
  • 575
  • 7
  • 29
0

You can use list() to convert tuple to list and appending the result in an array.

arr1 = [('1',), ('2',), ('3',)]
arr2 = []
for ele in arr1:
    arr2 = arr2+list(ele)

print(arr2) //['1', '2', '3']
Santhosh Kumar
  • 543
  • 8
  • 22
0

You can use extend method of list

l1=[('1',), ('2',), ('3',)]
result=[]
for data in l1:
    result.extend(data)
print(result)
Sapan Zaveri
  • 490
  • 7
  • 18