Last active
December 5, 2019 01:12
-
-
Save FerdinaKusumah/3422c91205ea9e5a06c5b1eac17bfe5e to your computer and use it in GitHub Desktop.
Flatten LIst
This file contains 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 list from nested list""" | |
a = [[1, 2], [3, 4], [5, 6]] | |
flat_list = list(chain(*a)) | |
print("Flatten list = {}".format(flat_list)) | |
# Flatten list = [1, 2, 3, 4, 5, 6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment