Created
July 28, 2020 14:01
-
-
Save FerdinaKusumah/dbe0966d0c46eecaa288545269ae947b to your computer and use it in GitHub Desktop.
[Python] flatten list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import chain | |
"""Flatten nested list""" | |
num = [[1, 2, 3], [4, 5, 6]] | |
flat_list = list(chain(*num)) | |
# flat list is [1, 2, 3, 4, 5, 6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment