Python program to print the list of all leap years
kw.py
print("________________________________________")print("Program to print the list of all leap years")print("________________________________________")y=int(input("How many years you want to print "))if(y<1):print("Enter the valid number of years")else:lc=0foriinrange(y):year=2024+iif(year%4==0):if(year%100==0):if(year%400==0):print("{0} is a leap year".format(year))lc=lc+1else:print("{0} is not a leap year".format(year))else:print("{0} is a leap year".format(year))lc=lc+1else:print("{0} is not a leap year".format(year))print("Total leap years between 2024 to {0} is".format(year),lc)print("________________________________________")
Output
kodingwindow@kw:~$ python3 kw.py
________________________________________
Program to print the list of all leap years
________________________________________
How many years you want to print 15
2024 is a leap year
2025 is not a leap year
2026 is not a leap year
2027 is not a leap year
2028 is a leap year
2029 is not a leap year
2030 is not a leap year
2031 is not a leap year
2032 is a leap year
2033 is not a leap year
2034 is not a leap year
2035 is not a leap year
2036 is a leap year
2037 is not a leap year
2038 is not a leap year
Total leap years between 2024 to 2038 is 4
________________________________________
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.