flatten a list of list

Paul Rubin http
Sun Aug 16 19:40:41 CEST 2009


Terry <terry.yinzhe at gmail.com> writes:
> Is there a simple way (the pythonic way) to flatten a list of list?
> rather than my current solution:
> 
> new_list=[]
> for l in list_of_list:
>     new_list.extend(l)

from itertools import chain
new_list = list(chain(list_of_list))



More information about the Python-list mailing list