flatten a list of list

Alan G Isaac alan.isaac at gmail.com
Sun Aug 16 19:37:04 CEST 2009

On 8/16/2009 5:47 AM Terry apparently wrote:
> 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)

new_list = list(xi for lst in list_of_list for xi in lst)

Alan Isaac

More information about the Python-list mailing list