Answers for "flattening 2d array in python"

1

flatten a 2d array python

arr_2d = [[1, 2, 3], [4, 5, 6]]
arr_1d = [el for arr in arr_2d for el in arr]
print(arr_1d) # [1, 2, 3, 4, 5, 6]
Posted by: Guest on May-18-2021

Python Answers by Framework

Browse Popular Code Answers by Language