Sobes.tech
Junior — Senior

The impact of list element changes on related variables

livecode

Task condition

It is necessary to understand how the contents of variables change when one list is assigned to another, and then its elements are increased in a loop. What output will be obtained?

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

for i in range(len(b)):
    b[i] += 1

print(a)
print(b)
The impact of list element changes on related… - sobes.tech