You are viewing a single comment's thread. Return to all comments →
You can just reverse the order and it will be fine.
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:
if year % 400 == 0:
if year % 100 == 0:
if year % 4 == 0:
This passes all the test cases.
i will mark your words
not passes year %100 == 0 test
Why wouldn't 1992 return true if % 4 == 0 is the first statement? it divides cleanly by 4 with no remainder, yet it gives false in the original scenario.
why we have to change elif statements to if statements sir??
i did the same thing but it's not working for year 2100
2100 is a leap year,but according to the compiler we should get False.
I reversed the order and it passed all the tests.
But i dont know why it did.
what did the reversing the order do??