List Mutation on Python
<p>I tried mutating a list by swapping a common element between the list and another reference list with the first element. The implementation is as shown below:  </p>

<pre><code>&gt;&gt;&gt; L = [1,2,3,4,5,6,7,8,9]
&gt;&gt;&gt; A = [3]
&gt;&gt;&gt; L[0], L[L.index(A[0])] = L[L.index(A[0])], L[0] #want to swap 3 with 1  
&gt;&gt;&gt; L 
[1,2,3,4,5,6,7,8,9,] #List L was not mutated  
</code></pre>

<p>The list was not mutated as I anticipated. But when I modify the implementation as shown below, it worked:  </p>

<pre><code>&gt;&gt;&gt; L = [1,2,3,4,5,6,7,8,9]
&gt;&gt;&gt; A = [3]
&gt;&gt;&gt; i = L.index(A[0])
&gt;&gt;&gt; L[0], L[i] = L[i], L[0]
&gt;&gt;&gt; L
[3,2,1,4,5,6,7,8,9,] #Now list mutated as desired even though L[i] and L[L.index(A[0])] evaluate to same value.  
</code></pre>

<p>My question is, why couldn't the first assignment mutate the list? I thought of it but my brain coudnt explain it.</p>
