+ 1

23.2 Leap year challenge issue

Hi, I checked all comments first, but not sure why this won't work for all cases. Any explanation would be greatly appreciated. Thanks. year = int(input()) #your code goes here if year%4 != 0: print ("Not a leap year") elif year%100 != 0: print("Not a leap year") elif year%100 != 0: print("Not a leap year") elif year%400 != 0: print("Not a leap year") else: print("Leap year")

31st Mar 2021, 2:39 PM
k2hawk 10
k2hawk 10 - avatar
4 Réponses
+ 4
https://code.sololearn.com/cCupNWmi3x6Q/?ref=app See I made some changes in ur code. May be this will help you.
31st Mar 2021, 2:48 PM
Kǟrɨsɦmǟ ❥
Kǟrɨsɦmǟ ❥ - avatar
+ 2
You're welcome 🤗
7th Apr 2021, 5:48 AM
Kǟrɨsɦmǟ ❥
Kǟrɨsɦmǟ ❥ - avatar
7th Apr 2021, 5:47 AM
k2hawk 10
k2hawk 10 - avatar
0
It says the year is NOT a leap year if it is evenly divisible by 100. So it should be: elif year % 100 == 0 print("Not a leap year") (And there are two code blocks written to check if the year is evenly divisible by 100 or not in your code. You only need one, right?)
18th Oct 2021, 12:03 PM
Moe Thae Nwe
Moe Thae Nwe - avatar