Pls help me solve this if else python problem

Write a program to check if a year is leap year or not.
If a year is divisible by 4 then it is leap year but if the year is century year like 2000, 1900, 2100 then it must be divisible by 400.

This Will Do!

year = int(input())
leap = ""
if (year % 4 == 0):
    leap = "YES"
    if (year % 100 == 0):
        if (year % 400 != 0):
            leap = "NO"
print(leap)

this should work!

year = int(input())
leap = False

if (year % 4 == 0):
    leap = True
    if (year % 100 == 0):
        if (year % 400 != 0):
            leap = False

if (leap):
    print(year, "is a leap year!")
else:
    print(year, "is not a leap year!")
1 Like