creating lists question?

wes weston wweston at
Wed Mar 24 05:27:09 CET 2004

spisatus wrote:
> I'm trying to create a series of list from a loop is this possible? Let me
> give you an example:
> list1 = ["aaa", "bbb", "ccc", "ddd", "eee"]
> for element in list1:
>   a = element         #a is one of the strings
>   a = []              #a is now an empty list; list1 is unchanged
> I want a new list created for every element in list1, how can I do this.
> Thanks!!
> Spisatus

    Let me just put comments on the for loop.
    There has to be a better way/better result than having a
bunch of named lists. Maybe you want a list of a label-list;
for example.

list = []
list.append( ["aaa",[]] )


print list
[['aaa', ['a']]]


More information about the Python-list mailing list