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.
As per the requirement I've created a function and satisfy the possible condition that question mention but I'm confused in this part (This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.) Here we need to apply some condition
def is_leap(year):
return (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0)
year = int(input())
print(is_leap(year))
Cookie support is required to access HackerRank
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 →
As per the requirement I've created a function and satisfy the possible condition that question mention but I'm confused in this part (This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.) Here we need to apply some condition
def is_leap(year): return (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0)
year = int(input()) print(is_leap(year))