Whey is_leap_year returning None instead of True
<p>Why does this code print None instead of True. It seems that once it checks if it divisible by 4 it does not go on to check the other requirements. From my current understanding, for each successive if statement it should keep going down and checking the next if until one of them is false. At which point it should go the the else statement and return False. But, obviously I'm doing something wrong. Thank you.</p>

<pre><code>def is_leap_year(year):
        # step 1 check if dvisible by 4
        if year % 4 == 0:
            print "year is divisble by 4"
            # step 2 check if divisible by 100
            if year % 100 == 0:
                print "year is divisible by 100"
                # step 3 check if divisble by 400
                if year % 400 == 0:
                    print "year is divisible by 400"
                    return True
        else:
            return False

print is_leap_year(1996)
</code></pre>

<p>You can use this approach:</p>

<pre><code>def is_leap_year(year):
    leap = False

    # step 1 check if dvisible by 4
    if year % 4 == 0:
        print "year is divisble by 4"
        leap = True

    # step 2 check if divisible by 100
    if year % 100 == 0:
        print "year is divisible by 100"
        leap = False

    # step 3 check if divisble by 400
    if year % 400 == 0:
        print "year is divisible by 400"
        leap = True

    return leap    
print is_leap_year(1996)
</code></pre>

<p>Explanation: year is leap if it is dividable by 4, and not leap if is dividable by 100 (unless it is also dividable by 400).</p>

python