Hey Matt,

Matt Smith wrote:
> I guessed that there would be a module out
> there providing a function to do this but wanted to go through the
> process as a learning exercise.
Good form, old boy.


> Here is the final code I have come up with, any comments?
I think your code looks fine.  I like to do the following, just to be a
little more concise:

def is_leap_year(year):
    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)

That is, the 'if' in your code is evaluating the statement into a
boolean.  Why not just return the results of that evaluation?
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to