参考 1段ネストしたリストをflattenする方法 Making a flat list out of list of lists in Python - Stack Overflow 2段以上ネストしたリストをflattenする方法 Flatten (an irregular) list of lists in Python - Stack Overflow Right Foot In: More on python flatten 色々方法があるみたいなので書留め。 1段ネストしたリストをflattenするとは つまり、 l = [[1,2,3],[4,5,6], [7], [8,9]] を [1,2,3,4,5,6,7,8,9] にするということ。 reduceを使った方法 reduceを使ってリストを畳み込むことができる。 reduce(lambda x,y: x+y,l) 組込み
![Pythonでリストをflattenする方法まとめ - Soleil cou coupe](https://cdn-ak-scissors.b.st-hatena.com/image/square/450d90d508ad51de906176a722623df3790ae97a/height=288;version=1;width=512/https%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fx%2Fxef%2F20121027%2F20121027192019.png)