[ / / / / / / / / / / / / / ] [ dir / agatha2 / animu / ausneets / b2 / choroy / dempart / freeb / vichan ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Email
Comment *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): 167f6592f409207⋯.png (739 B, 275x114, 275:114, out.png) (h) (u)

[–]

 No.1072727>>1072738 >>1072811 [Watch Thread][Show All Posts]

Hello /tech/, do you know your Python?

If so, then why does the following code:


arr = [[0] * 2] * 3
[print (arr [x][0]) for x in range (3)]
arr [0][0] = 1
print ("New:")
[print (arr [x][0]) for x in range (3)]

print:


0
0
0
New:
1
1
1

?

 No.1072738>>1072832 >>1072840

>>1072727 (OP)

>>733048

(0*2)*3=0

But I have neverever coded so my answer could be wrong.


 No.1072740

Because when you multiply an array it copies by reference.


 No.1072811

>>1072727 (OP)

Because nested arrays are painful in Python.

t.faggot who had to use deepcopy more than once


 No.1072832

>>1072738

>But I have neverever coded so my answer could be wrong.

Why did you post that then you fucking retarded nigger


 No.1072840

>>1072738

That's an array you dumbfuck


 No.1072842

/tech/ is not here to do your homework you fucking faggot




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
6 replies | 0 images | Page ???
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / agatha2 / animu / ausneets / b2 / choroy / dempart / freeb / vichan ][ watchlist ]