flatten.py 494 Bytes
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
# Author: Brice Colombier
# Laboratoire Hubert Curien
# 42000 Saint-Etienne - France
# Contact: b.colombier@univ-st-etienne.fr
# Project: CASCADE
# File: flatten.py
# Date : 2016-10-12

from itertools import chain


def flatten(liste):

"""Turns a list of lists into a list.

>>> flatten([[1, 2], [3, 4]])
[1, 2, 3, 4]
"""

liste = list(chain.from_iterable(liste))
return liste

if __name__ == "__main__":
print flatten([[0, 1, 2, 3], [4, 5, 6, 7]])