# Python program to check Leap year: Beginners Guide

*Summary:*

This is one of the most confusing problems for beginners which they find hard to understand. I will try to explain the Python program to check leap year in an easy way.

A year is a leap year if it satisfies **any** of the conditions.

- Completely divisible by 400
- Divisible by 4 and NOT divisible by 100

The logic is easy to implement in any language.

You can learn the maths of leap year with examples from here.

## Python Program: Check Leap year

This is a general Python program to find leap year which can be easily implemented in other languages also.

Copy

```
year = int(input("Enter the year: "))
if(year%400==0):
print("It is leap year")
elif(year%4==0 and year%100!=0):
print("It is leap year")
else:
print("It is Not leap year")
```

Output

Enter the year: 2019 It is Not leap year

The logic of the Python code is the same as described above to check leap year.

Take the input from the user and convert it to the integer type. If the year is completely divisible by 400 then it is a leap year.

If the year is completely divisible by 4 and not divisible by 100 then it is a leap year. Else it is Not a leap year.

## One-Line Python Program

Copy

```
year = int(input("Enter the year: "))
print((year%400==0) or (year%4==0 and year%100!=0))
```

Output

Enter the year: 2020 True

I know the program contains two lines 🙂 but we need user input.

The logic is the same as described condition to check leap year.

Related Python Examples: