Sololearn to learn Python and I got stuck with that exercise.
Task conditions: You need to make a program to take a year as input and output “Leap year” if it’s a leap year, and “Not a leap year”, if it’s not.
To check whether a year is a leap year or not, you need to check the following:
- If the year is evenly divisible by 4, go to step 2. Otherwise, the year is NOT a leap year.
- If the year is evenly divisible by 100, go to step 3. Otherwise, the year is a leap year.
- If the year is evenly divisible by 400, the year is a leap year. Otherwise, it is not a leap year.
Sololearn is hiding some test cases to avoid cheating. There are 7 test cases and 2 of them is failed.
What am I missing?
Well you should rethink your code: if we input the year 4 (which is a leap year) what will the output of your code be?
Here is the rule to know if a year is a leap year:
To be a leap year, the year number must be divisible by four – except for end-of-century years, which must be divisible by 400. This means that the year 2000 was a leap year, although 1900 was not. 2020, 2024 and 2028 are all leap years.