flatten 28 29 python

Solutions on MaxInterview for flatten 28 29 python by the best coders in the world

showing results for - " flatten 28 29 python"
Luigi
20 Jan 2018
1def flatten(L):
2    for item in L:
3        try:
4            yield from flatten(item)
5        except TypeError:
6            yield item
7
8list(flatten([[[1, 2, 3], [4, 5]], 6]))
9>>>[1, 2, 3, 4, 5, 6]
10
Kimberley
31 Jul 2020
1>>> a = np.array([[1,2], [3,4]])
2>>> a.flatten()
3array([1, 2, 3, 4])
4>>> a.flatten('F')
5array([1, 3, 2, 4])