TechieClues TechieClues
Updated date Mar 22, 2021
In this code snippet, we will see how to check a year is a leap year or not in python.
  • 1.4k
  • 0
  • 0

Python program to check a year is a leap year or not. Below is a code snippet,

# To check if the year is a leap year or not in Python

year = int(input("Enter a year to check : "))

if ((year % 4) == 0 and (year % 100) != 0) or ((year % 400) == 0):
    print("{0} is a leap year".format(year))
else:
    print("{0} is not a leap year".format(year))

Output 1:

Enter a year to check: 2020
2020 is a leap year

Output 2:

Enter a year to check: 2021
2021 is not a leap year

ABOUT THE AUTHOR

TechieClues
TechieClues

I specialize in creating and sharing insightful content encompassing various programming languages and technologies. My expertise extends to Python, PHP, Java, ... For more detailed information, please check out the user profile

https://www.techieclues.com/profile/techieclues

Comments (0)

There are no comments. Be the first to comment!!!