a = [1,2,3,4,5]
acopy1=a
acopy2 = a.copy()
print(a)
print(acopy2)
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5]
In [15]:
a [3]= "hello"
print(a)
print(acopy2)
[1, 2, 3, 'hello', 5] [1, 2, 3, 4, 5]
In [16]:
m = ['a', 'b', 'c']
n = [1, 2, 3]
x = [m, n]
y = x.copy()
print('x=',x)
print('y=',y)
x= [['a', 'b', 'c'], [1, 2, 3]] y= [['a', 'b', 'c'], [1, 2, 3]]
In [17]:
x[0][0] = 1
print('x=',x)
print('y=',y)
x= [[1, 'b', 'c'], [1, 2, 3]] y= [[1, 'b', 'c'], [1, 2, 3]]