Python Programs Written and Practiced by : Jiya Kiyam

File Name : leap_year.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
"""
Program Name: Leap Year Checker
Description: Check if a year is leap or not
"""
valid = False
while not valid :
  year = input("Enter the year to check if leap : ")

  if year.isdigit() and len(year) == 4 :
    valid = True
  else :
    print("Enter year in correct format 'YYYY'")

year = int(year)
if year % 4 == 0 :
  print(f"{year} is a leap year")
else :
  print(f"{year} is not a leap year")

Run Back to programs