Lists & two dimensions

Terry Reedy tjreedy at udel.edu
Sat Jul 20 11:28:20 EDT 2002


"Pichai Asokan" <asokanp at virtusa.com> wrote in message
news:bed1f696.0207200546.2bca2e34 at posting.google.com...
> I thought
> board = [[-1] * 3 ]*3
> should give me a list of 9 elements;
> but ...

List 'multiplication' is NOT associative.  You get list with three
references to (one) list with three references to int -1.

TJR





More information about the Python-list mailing list