Why does my variable's value is changed by a line that doens't touch it in Python?
<p>The answer to my question seems pretty straightforward : it can't so it doesn't. Yet I believe it is happening to me and it is driving me fairly crazy. Therefore I would very much appreciate your opinion.</p>

<p>Here's the situation. I'm writing this script which has the following function in it :</p>

<pre><code>    def ReduceReferenceCode():

        Code = ReferenceCode

        if E == 7:
            CritLimit = 2
        elif E == 4:
            CritLimit = 1

        if D &lt; CritLimit:
            for i in [4, 5, 6]:
                if Code[i] &gt;= CritLimit:
                    print ReferenceCode
                    Code[i] = Code[i] - CritLimit
                    print ReferenceCode
                    break
        else:
            Code[7] = Code[7] - CritLimit
        Code[9] = 1

        return Code
</code></pre>

<p>The value of my <strong>ReferenceCode</strong> variable - which is passed as an argument to the program with sys.argv - is changed between the two print commands. My main function prints both <strong>ReferenceCode</strong> and my reduced code for comparison purposes, which is the value stored in <strong>Code</strong></p>

<p>Here's the program's output:</p>

<pre><code>    [1, 4, 3, 4, 9, 7, 2, 0, 6, 7, 9, 2]
    [1, 4, 3, 4, 7, 7, 2, 0, 6, 7, 9, 2]
    The reference code is [1, 4, 3, 4, 7, 7, 2, 0, 6, 1, 9, 2] and the reduced reference code is [1, 4, 3, 4, 7, 7, 2, 0, 6, 1, 9, 2]
</code></pre>

<p>Both variables should not have the same value and I really don't see why the operation on <strong>Code</strong>[i] is affecting <strong>ReferenceCode</strong>'s value.</p>

<p>Any insight would be highly appreciated :-)</p>