0
Python List append
Can you explain the behind the scenes of the output of this code ? a = [1,2] b = [1,2] a.append (b) b.append (a) print(a) print(b) https://code.sololearn.com/cCFgkfxZwrUz/?ref=app
2 Respostas
+ 3
Both append statements add a third element to the list, which is a reference to the other list. Therefore it creates an endless circular reference between these two lists.
Python detects this infinite loop and expresses it with the [...] or Ellipsis symbol.
Check out this thread too:
https://www.sololearn.com/discuss/1874398/?ref=app
+ 2
Thank you Tibor Santa