LoginSignup
0
2

More than 3 years have passed since last update.

Python で flatten

Posted at

環境

関数等は特に使わないのでなんでもよい.

import sys
print(sys.version)
# 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 18:10:19) 
# [GCC 7.2.0]

Code

nested = [[1, 2, 3],
          [4, 5, 6],
          [7, 8, 9]]

flatten = []
for inner in nested:
    flatten += inner

flatten
# [1, 2, 3, 4, 5, 6, 7, 8, 9]
0
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2