• + 25 comments

    Reversing the order almost works, but you have to add an else block returning False at the end to capture cases where none of the if blocks execute (like for the year 1992) and also change all elif statements to if statements. I.e:

    def is_leap(year):
        if year % 400 == 0:
            return True
        if year % 100 == 0:
            return False
        if year % 4 == 0:
            return True
        else:
            return False
    

    This passes all the test cases.