Leap Year Check
Programs with input · Beginner · about 5 min
Read a year and print whether it is a leap year, as 2024 is a leap year or 2023 is not a leap year. The rule has three parts:
- a year divisible by 4 is a leap year,
- except a year divisible by 100, which is not,
- unless it is also divisible by 400, which makes it a leap year again.
The prompts inside input() are not checked, only what you print.
Examples
You type:
2024The program prints:
2024 is a leap year
You type:
2023The program prints:
2023 is not a leap year
year = int(input("Year: "))
# Print whether it is a leap year
The solution opens after your first Check.