Re: Unexpected behavior of list of list

2007-03-09 Thread kghose
On Mar 9, 8:30 pm, "kghose" <[EMAIL PROTECTED]> wrote: > Hi, > > The following code > > listoflists = [[]]*2 > listoflists[0].append(1) > > appends(1) to both listoflists[0] and listoflists[1] (which I did not > expect) > > while > > list

Unexpected behavior of list of list

2007-03-09 Thread kghose
Hi, The following code listoflists = [[]]*2 listoflists[0].append(1) appends(1) to both listoflists[0] and listoflists[1] (which I did not expect) while listoflists = [[]]*2 listoflists[0] = [1] listoflists[0].append(2) works as expected.i.e. only listoflists[0] gets 2 appended to it and any