Answers for "how to make 2d list to 1 d list in python"

1

convert 2d list to 1d python

import itertools

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

Output:- [1, 2, 3, 4, 5, 6]
Posted by: Guest on August-27-2021
0

how to create one list from 2d list python

>>> l = [[1, 2, 3], [4, 5, 6], [7], [8, 9]]
>>> sum(l, [])
[1, 2, 3, 4, 5, 6, 7, 8, 9]
Posted by: Guest on October-24-2021

Code answers related to "how to make 2d list to 1 d list in python"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language