Skip to content

Instantly share code, notes, and snippets.

@FerdinaKusumah
Last active December 5, 2019 01:12
Show Gist options
  • Save FerdinaKusumah/3422c91205ea9e5a06c5b1eac17bfe5e to your computer and use it in GitHub Desktop.
Save FerdinaKusumah/3422c91205ea9e5a06c5b1eac17bfe5e to your computer and use it in GitHub Desktop.
Flatten LIst
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