First time here? Checkout the FAQ!
x
0 votes
212 views
asked in General by (500 points)  
edited by
  

1 Answer

0 votes
answered by (500 points)  

The best way is to how b is copied below. As we can see, a is impacted by any changes we make on c but not b, 

a = [1,2,3]
b=a[:]
c=a

b.append(99)
c.append(4)
print ("a=",a,"b=",b,"c=",c)

outputs 

a= [1, 2, 3, 4] b= [1, 2, 3, 99] c= [1, 2, 3, 4]

 

...