+ 3
Hello, can anybody please explain me, why the code is doing what he does?
Python array-problem when appending itself https://code.sololearn.com/cd6fn9ny1pPE/?ref=app
7 odpowiedzi
+ 5
Found a post that was telling about exactly the same problem you got
https://www.google.com/amp/s/asmeurersympy.wordpress.com/2012/09/19/infinitely-nested-lists-in-JUMP_LINK__&&__python__&&__JUMP_LINK/amp/
+ 3
//it is appending a inside a[] [[]]
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2433/?ref=app
+ 1
Sure, but it's returning [[...]]
Imo, either it should be [[]], because it copies the value of the array, or it should return an error, because the value is a reference to itself, which would end up in an infinite loop.
Or does the ... mean, that it contains vague values?
+ 1
Hm, seems, that the "..." means, there is vague content. I wonder, if there is any useful reason to not return an error.
Thank you for your answers
0
You added array a into array a. If you set the array to [1, 2] instead, the output would be:
[1, 2, [1, 2]]
0
No, the output would be [1,2,[1,2,[1,2,[...]]]].
Python handles the problem by replacing the recursive array through "..." -> [1,2,[...]]
0
len (a) shows 1
Maybe similar to normal appending same empty array is appended in it but only once.
[...] Does this changes with more no. of element or not!!