Se7enSquared
10/18/2019 - 5:56 PM

Convert 2-D list to 1-D

Convert a nested (2D) list of lists into a single dimensional list

import itertools  
a = [[1, 2], [3, 4], [5, 6]] 
print(list(itertools.chain.from_iterable(a))) 

# output: [1, 2, 3, 4, 5, 6]