how to flatten one level of list of lists?

Tim Gahnström /Bladerman tim at bladerman.com
Tue May 29 14:15:05 EDT 2001


"George Young" <gry at ll.mit.edu> skrev i meddelandet
news:3B13DE0C.76270DAA at ll.mit.edu...
> I have a list like:
>   l = [[2], [3], [5], [11]]
> and I want to get:
>   ll = [2, 3, 5, 11]

Dont know if this is easier but it will work
for i in l:
    ll.extend(i)

Tim





More information about the Python-list mailing list