Message159899
| 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:42 | darrell | set | recipients:
+ darrell |
| 2012年05月04日 04:13:42 | darrell | set | messageid: <1336104822.52.0.958479666589.issue14719@psf.upfronthosting.co.za> |
| 2012年05月04日 04:13:41 | darrell | link | issue14719 messages |
| 2012年05月04日 04:13:41 | darrell | create |
|