Talk:Spiral matrix: Difference between revisions
Content added Content deleted
Line 272: | Line 272: | ||
== Python array initialisation edit problem == |
== Python array initialisation edit problem == |
||
Hi Spoon, your edit to Spiral of substituting <python>array = [[None]*n]*n</python> for <python>array = [[None]*n for j in range(n)]</python> [[http://www.rosettacode.org/w/index.php?title=Spiral&curid=2967&diff=16906&oldid=16746 here]] doesn't work because of: |
Hi Spoon, your edit to Spiral of substituting <python>array = [[None]*n]*n</python> for <python>array = [[None]*n for j in range(n)]</python> [[http://www.rosettacode.org/w/index.php?title=Spiral&curid=2967&diff=16906&oldid=16746 here]] doesn't work because of: |
||
<python>>>> n=2 |
<lang python>>>> n=2 |
||
>>> a = [[None]*n]*n |
>>> a = [[None]*n]*n |
||
>>> a |
>>> a |
||
Line 279: | Line 279: | ||
>>> a |
>>> a |
||
[[1, None], [1, None]] |
[[1, None], [1, None]] |
||
>>></ |
>>></lang> |
||
You are referencing the inner list multiple times instead of creating new copies. --[[User:Paddy3118|Paddy3118]] 06:17, 14 August 2008 (UTC) |
You are referencing the inner list multiple times instead of creating new copies. --[[User:Paddy3118|Paddy3118]] 06:17, 14 August 2008 (UTC) |
||
:Oh yeah, sorry. You're right. --[[User:Spoon!|Spoon!]] 18:58, 14 August 2008 (UTC) |
:Oh yeah, sorry. You're right. --[[User:Spoon!|Spoon!]] 18:58, 14 August 2008 (UTC) |