Question: Still new, I searched google but I didn't really find an explanation so thank you in advance. When writing Python, why is is that during a while loop, a variable that is assigned a list outside of the while loop can be modified and retain it's modifications with each iteration, but a variable that is assigned a list during the loop will revert back to it's original assignment with each iteration? Here is an example code:

```
x = [1,1,1]

while True:
    a = [1,1,1]
    b = x
    a.append(1)
    b.append(2)
    print(a)
    print(b)

```

why does variable a stay the same, while variable b can be appended with each iteration and maintain its modifications? Thanks.

Answer: 
It's because `a` is redefined at each iteration, while `b` isn't. When you write `b = x`, you only link b to x, and modifying `b` in your loop is in fact changing only the list that it refers to, the same list that `x` refers to which isn't redefined at each iteration (unlike `a`).
This is a classic case of Shallow Copy vs Deep Copy.

This code below will give you results as expected by you.

```
import copy
x = [1,1,1]

while True:
    a = [1,1,1]
    b = copy.deepcopy(x)
    a.append(1)
    b.append(2)
    print(a)
    print(b)

```

Assignment statements by default do not copy objects, they create bindings between a target and an object.

Shallow copy is by default.
To completely copy the values, we need deepcopy as shown in the above code