Incorrect Question 6 Consider the following code: listi [1,2,3] list2 = [5,list1
ID: 3905267 • Letter: I
Question
Incorrect Question 6 Consider the following code: listi [1,2,3] list2 = [5,list1,6] print(list2) # line A: listi[1] "?" print(list2) # line B: prints [5, [1, 2, 3], 6] prints [5, [1, "X", 3, 6] Why does changing an element in list1 changes also list2? the assignment the assignment list2 [5,list1,6] tells Python to copy all elements of list1 to list2. .You selected this answer tells Python to copy all elements of list1 to list2 the assignment list2-[5,list1,6] makes a deep copy of list1 ist2[1] and list1 are references to the same object Python makes a copy in list2[1] of list1 and any changes to list 1 are propagated to list2[1].tooExplanation / Answer
Given list1 = [1,2,3]
list2 = [5,list1,6]
Here second element of list2 is the entire list1
When we change list1, list2 will also get updated, because list1 and list2[1] are pointing to the same object. So, chaning one, will automatically change the list1.
So, ans is (c) list2[1] and list1 are references to the same object