Nested lists, simple though

George Sakkis george.sakkis at gmail.com
Sun Apr 20 18:59:01 EDT 2008


On Apr 20, 6:50 pm, Jason Scheirer <jason.schei... at gmail.com> wrote:
> On Apr 20, 3:25 pm, Zethex <zet... at hotmail.com> wrote:
>
>
>
> > Im a bit new to python.  Anyway working on a little project of mine and i
> > have nested lists
>
> > ie
>
> > Answer = [['computer', 'radeon', 'nvidia'], ['motherboard', 'asus']]
>
> > and so forth..,
> > Anyway the amount of [[]] do increase over time.  Im just wondering is there
> > a simple way to add these together so they become 1 simple list, so it would
> > be ['computer'....'asus'] etc without the nested list.  Its random the
> > amount each time so i cant just go a[0]+a[1].
> > Thank you if you can help
> > --

> The first idea that comes to mind is reduce(lambda x, y: x + y,
> list_of_lists, [])

s/first/worst/

There, I fixed it for you.



More information about the Python-list mailing list