Skip to content

Instantly share code, notes, and snippets.

@FerdinaKusumah
Created July 28, 2020 14:01
Show Gist options
  • Save FerdinaKusumah/dbe0966d0c46eecaa288545269ae947b to your computer and use it in GitHub Desktop.
Save FerdinaKusumah/dbe0966d0c46eecaa288545269ae947b to your computer and use it in GitHub Desktop.
[Python] flatten list
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