Question: Why is the following program incorrect given that the user wants print ( b ) to display: [ 4 , 5 , [ 1 ,

Why is the following program incorrect given that the user wants print(b) to display:
[4,5,[1,2,3]]
a =[1,2,3]
b =[4,5, a ]
a[1]='d'
print(b)
Python
b=[4,5,a] is a copy of list a. In other words, list b only contains a copy to list a.
Any changes to list a will be reflected in list b since b's entry for list a is a copy of
the original list.
b=[4,5,a] uses a pointer to reference the list a. In other words, list b only contains
a pointer to list a. Any changes to list a will be reflected in list b since b's entry
for list a points to the original list.
This is impossible. There does not exist a programming technique, in Python, to
do what the programmers wants to accomplish.
Why is the following program incorrect given that

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!