+ 5

I don't understand how list elements get appended to the second list l2 in the below code. Do you?

https://code.sololearn.com/cDYCzpQKApY8/?ref=app

9th Mar 2020, 7:00 AM
Sonic
Sonic - avatar
5 odpowiedzi
+ 10
cool try this at end of your code for l in l2: print(id(l)) it will clarify the case😉
9th Mar 2020, 7:08 AM
Oma Falk
Oma Falk - avatar
+ 9
HonFu thanks. You should write a book called "Python Simplified" or something like that 😉.
9th Mar 2020, 8:13 PM
Sonic
Sonic - avatar
+ 7
Sonic, have you read my brand-new tutorial about references yet? :) https://code.sololearn.com/c89ejW97QsTN/?ref=app
9th Mar 2020, 8:37 AM
HonFu
HonFu - avatar
+ 6
Sonic yes that's it👍
9th Mar 2020, 7:20 AM
Oma Falk
Oma Falk - avatar
+ 5
Oma Falk thanks, so it means that in each iteration, what's being appended to l2 is just a reference to l1 ?
9th Mar 2020, 7:18 AM
Sonic
Sonic - avatar