How to determine whether a year is a leap year in Python?
Question: I am trying to make a simple calculator to determine whether or not a certain
year is a leap year.

By definition, a leap year is divisible by four, but not by one hundred,
unless it is divisible by four hundred.

Here is my code:

    
    
    def leapyr(n):
        if n%4==0 and n%100!=0:
            if n%400==0:
                print n, " is a leap year."
        elif n%4!=0:
            print n, " is not a leap year."
    print leapyr(1900)
    

When I try this inside the Python IDLE, the module returns **None**. I am
pretty sure that I should get **1900 is a leap year**.


Answer: 
    import calendar
    print calendar.isleap(1900)
    

Python provides this functionality already in the library module 'calendar'.

