>>> import operator >>> l = [[1,2,3],[4,5,6], [7], [8,9]] >>> reduce(operator.concat, l) [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> l [[1, 2, 3], [4, 5, 6], [7], [8, 9]] >>> reduce(operator.add, l) [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> reduce(lambda x, y: x+y, l) [1, 2, 3, 4, 5, 6, 7, 8, 9]
解法としてはこうなるんだろうけど、なんでflattenされるのか謎