X = Y = Lists vs Numbers : <p>In python : I have 2 pieces of code behaving different when I modify values:</p>

<p>X = Y = Number</p>

<pre><code>x = y = 2
x = 3

print(x)
print(y)

Output:
3
2
</code></pre>

<p>X = Y = [List]</p>

<pre><code>x = y = ['a','b']
x[0] = 'd'

print(x)
print(y)

Output:
['d', 'b']
['d', 'b']
</code></pre>

<p><strong>Why don't LISTS respect the original value of variable Y if X is changed?</strong> </p>
