i = [1, 2, 3, 4, 5]
j = i
j[0] = 100
print('j = ', j)
print('i = ', i)
x = [1, 2, 3, 4, 5]
y = x.copy() # y =x[:]と書いても同じ処理が行えるがわかりにくいので推奨しない
y[0] = 100
print('y = ', y)
print('x = ', x)
出力
j = [100, 2, 3, 4, 5]
i = [100, 2, 3, 4, 5]
y = [100, 2, 3, 4, 5]
x = [1, 2, 3, 4, 5]
X = 20
Y = X
Y = 5
print(Y)
print(X)
X = [ 'a', 'b']
Y = X
Y[0] = 'p'
print(Y)
print(X)
5
20
['p', 'b']
['p', 'b']