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

import itertools as it


def flatten(liste):

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

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

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