Beginner confused about why var1 doesn't change even though list [var1, var2] changes
<p>Very noob to python and programming overall.
Why does this code:</p>

<pre><code>def daysBetweenDates(year1, month1, day1, year2, month2, day2):
    years = [year1, year2]
    def leapyr(n):
        if n % 400 == 0:
            return True
        elif n % 100 == 0:
            return False
        elif n % 4 == 0:
            return True
        else:
            return False

    for i, year in enumerate(years):
        if leapyr(year):
            years[i] = year * 366
            print 'l:', years, year1, year2
        else:
            years[i] = year * 365
            print 'n:', years, year1, year2

daysBetweenDates(1,1,1,4,2,1)
</code></pre>

<p>Change year1 and year2 in years[ ], but does not change year1 and year2?</p>

<pre><code>n: [365, 4] 1 4
l: [365, 1464] 1 4
</code></pre>

<p><strong>edit: working code</strong></p>

<pre><code>def daysBetweenDates(year1, month1, day1, year2, month2, day2):
    years = [year1, year2]
    def leapyr(n):
        if n % 400 == 0:
            return True
        elif n % 100 == 0:
            return False
        elif n % 4 == 0:
            return True
        else:
            return False

    for i, year in enumerate(years):
        if leapyr(year):
            years[i] = year * 366
            year1 = years[0]
            year2 = years[1]
            print 'l:', years, year1, year2
        else:
            years[i] = year * 365
            year1 = years[0]
            year2 = years[1]
            print 'n:', years, year1, year2

daysBetweenDates(1,1,1,400,2,1)
</code></pre>

<p>Now gives correct answer:</p>

<pre><code>n: [365, 400] 365 400
l: [365, 146400] 365 146400
</code></pre>

<p>Your post looks like too much code, here put some more text here. Text is important.</p>
