+ 1
Can anyone say why we have got the following output for the given code ?
----------- Input : ----------- a=[1,2] a.append(a) print(a) print(a[2]) print(a[2][2]) print(a[2][2][2]) print(a!=a[2][2][2]) ------------- Output : ------------- [1,2,[...]] [1,2,[...]] [1,2,[...]] [1,2,[...]] False The code is given below ! 👇👇 https://code.sololearn.com/cVRtV2EtRX2K/?ref=app
2 Respostas
+ 6
By appending a to itself u r creating a potentially endless loop. a[2] is assigned to the same list object as a. So by trying to access it you always access the same list again.