We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Introduction
- Write a function
- Discussions
Write a function
Write a function
Sort by
recency
|
2944 Discussions
|
Please Login in order to post a comment
return (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
def is_leap(year): leap = False
year = int(input()) print(is_leap(year))
if(year%4==0 and year%100!=0) or (year%400==0): return True else: return False
this code has worked for me for all the test cases
if (year % 4 == 0): if (year % 100 == 0): if (year % 400 == 0): return True else: return False else: return True else: return False
Something is wrong with the compiler for this question. The test case for 1992 is not returning the same output when I Run Test with Custom Input vs Submit Code. I ran my code locally on my computer and 1992 returns FALSE since it is not a leap year. When I run the same code on the compiler it returns TRUE: def is_leap(year): leap = False
year = int(input()) print(is_leap(year))