Sabari M Sabari M
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.

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

Sabari M
Sabari M
Software Professional, India

IT professional with 14+ years of experience in Microsoft Technologies with a strong base in Microsoft .NET (C#.Net, ASP.Net MVC, ASP.NET WEB API, Webservices,...Read More

https://www.techieclues.com/profile/alagu-mano-sabari-m

Comments (0)

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