Need help on 6.00 Handout, Lecture 5: Here are the lists that I am looking at: 1. L1 =  L2 = [L1, L1] print 'L2 =', L2 # L2 = [, ] 2. L1 = 3 print 'L2 =', L2 # L2 = [, ] 3. L2 = 'a' print 'L2 =', L2 # L2 = ['a', ] 4. L1 =  L2 = L1 L2 = 'a' print 'L1 =', L1 print 'L2 =', L2 # L1 = ['a'] # L2 = ['a'] I understand everything up to number 4 (correct answers start with a #). I can't understand why L1 = 'a' here. I was expecting L1 to be equal to . Could someone write down an explanation about what is going on in part 4 of the
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
L2 and L2 are pointing to the same object in memory - This is why around 30mins in the video the programming keeps running. This is call Aliasing - one object with more then one name.
@tcc8m the first line sets L1 equal to a list that's big enough to contain two items. The second line sets L2 equal to L1 which means that they're both "equal to" or "pointing at" the same list. So when the third line sets the first member of the list to the value of 'a', both variables (since they're both pointing at /equal to the same list) get updated.