creating lists question?
wes weston
wweston at att.net
Tue Mar 23 23:27:09 EST 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",[]] )
list[0][1].append("a")
print list
[['aaa', ['a']]]
wes
More information about the Python-list
mailing list