On Fri, Sep 21, 2012 at 2:47 PM, Pavel Andreev <apn...@gmail.com> wrote: > > f=[[0]*3]*3 # array initialization
The above isn't giving you what you want. All 3 sublists are the same object: >>> f = [[0]*3]*3 >>> map(id, f) [149391980, 149391980, 149391980] Do this instead: >>> f = [[0]*3 for i in range(3)] Each iteration in the comprehension creates a new list: >>> map(id, f) [149392364, 149392012, 149392428] _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor