how to make a nested list

Stef Mientki stef.mientki at gmail.com
Thu Sep 15 18:57:24 CEST 2011


hello,

I need a nested list, like this

 >>> A= [ [None,None], [None,None], [None, None] ]
 >>> A[2][0] =77
 >>> A
[[None, None], [None, None], [77, None]]


Because the list is much larger, I need a shortcut (ok I can use a for loop)
So I tried
 >>> B = 3 * [ [ None, None ]]
 >>> B[2][0] = 77
 >>> B
[[77, None], [77, None], [77, None]]

which doesn't work as expected.

any suggestions ?

thanks,
Stef



More information about the Python-list mailing list