You are viewing a single comment's thread. Return to all comments →
For the learners: you should know that doing something like the setup for this challenge inclines you to do is a bad practice. Never do the following:
def f(): if condition: return True else: return False
This is just dumb. You are returning a boolean, so why even use if blocks in the first place? The correct what of doing this would be:
def f(): return condition
Because this already evaluates as a boolean.
So in this challenge, forget about ifs and elses, and that leap variable, and just do the following:
def is_leap(year): return year % 4 == 0 and (year % 400 == 0 or year % 100 != 0)
Don't be redundant, be DRY.
Seems like cookies are disabled on this browser, please enable them to open this website
Write a function
You are viewing a single comment's thread. Return to all comments →
For the learners: you should know that doing something like the setup for this challenge inclines you to do is a bad practice. Never do the following:
This is just dumb. You are returning a boolean, so why even use if blocks in the first place? The correct what of doing this would be:
Because this already evaluates as a boolean.
So in this challenge, forget about ifs and elses, and that leap variable, and just do the following:
Don't be redundant, be DRY.