I have such a nested array
In [12]: print(f"{arr}")
[[0, 1, 2], [7, 8, 9, 10], [12, 13, 14, 15, 16, 17]]
I want to concatenate the three arrays inside
arr = [[0, 1, 2], [7, 8, 9, 10], [12, 13, 14, 15, 16, 17]]
res, k = [], 0
for i in range(len(arr)):
for j in range(len(arr[i])):
res.append(arr[i][j])
or
In [26]: [arr[i][j] for i in range(len(arr)) for j in range(len(arr[i]))]
Out[26]: [0, 1, 2, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17]
How could use unpacking to handle the problem
In [27]: [*a for a in arr]
File "<ipython-input-27-4ab599207747>", line 1
[*a for a in arr]
^
SyntaxError: iterable unpacking cannot be used in comprehension