absolute newbie: divide a list into sublists (nested lists?) of fixed length

ergconcepts at googlemail.com ergconcepts at googlemail.com
Sat Apr 11 17:00:11 EDT 2009


On Apr 11, 10:37 pm, Andreas Pfrengle <a.pfren... at gmail.com> wrote:

> my_list = []
> for x in range(3):
>  my_list.append([])
>  for y in range(3):
>   my_list[x].append(some_value)

Thanks for your help - but I'm sorry I do not understand:


> my_list = []
I guess here you are implying to write something like
my_list = [ 0.84971586,  0.05786009,  0.9645675,  0.84971586,
0.05786009, 0.9645675, 0.84971586,  0.05786009,  0.9645675,
0.84971586, 0.05786009,  0.9645675]
?

then what would this do:
> my_list.append([])
?

and finally, what do you mean by "some_value"?
>   my_list[x].append(some_value)
of course, the value to append would always be the next one from my
list, and not one I would want to give explicitly each time..

I'm sorry if I did not make myself very clear before but I am
completely new to the python syntax and also to the technical terms..

Best regards,

Bernhard



More information about the Python-list mailing list