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
|
2641 Discussions
|
Please Login in order to post a comment
here is my answer def is_leap(year): leap = False
def is_leap(year): if year % 4 == 0: # Year evenly divisible by 4 if year % 100 == 0: # Year also divisible by 100 if year % 400 == 0: # Year divisible by 400 return True else: return False else: return True else: return False by writing this still getting error
if name == "main": year = int(input("Enter a year: ")) print(is_leap(year))
def is_leap(year): if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: return True else: return False else: return True else: return False
Example usage:
year = int(input()) print(is_leap(year))
def is_leap(year): if year % 400 == 0: return True elif year % 100 == 0: return False elif year % 4 == 0: return True else: return False