0

I am creating a list, x, and assigning another variable b to x. When I change the value of the first item in b, it is also changing the value of the first item in x.

This is the code I am executing.

x = [1]
b = x
b[0] = 2
print(x)

It is printing '[2]'

I expected the value of x to remain unchanged. I thought the code would print '[1]'

0 Answers0