Author darrell
Recipients darrell
Date 2012-05-04.04:13:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1336104822.52.0.958479666589.issue14719@psf.upfronthosting.co.za>
In-reply-to
Content
N = 5
board_1 = [[0 for _ in range(N)] for __ in range(N)]

is not the same as:

board_2= [[0]*N]*N

One makes a proper list of lists (the first), the second makes a new kind of animal were board_2[1][1] = 99 changes a whole column.

Oddly, testing board_1 == board_2 is True!

I'm teaching Python to non-majors, and this is a tough one to explain.
History
Date User Action Args
2012-05-04 04:13:42darrellsetrecipients: + darrell
2012-05-04 04:13:42darrellsetmessageid: <1336104822.52.0.958479666589.issue14719@psf.upfronthosting.co.za>
2012-05-04 04:13:41darrelllinkissue14719 messages
2012-05-04 04:13:41darrellcreate