0
Why won’t the code work when 2000 plugged in help please it’s for the leap year checker
year = int(input()) if (year % 4): if (year % 100): if(year % 400): print('leap year') else: print("Leap year") else: print('Not a leap year')
6 Respuestas
+ 5
It is because when you divide 2000 by 4 the remender will be 0 , and 0 is considered as False , if you want that condition be True then you can apply this if (year % 4 == 0) or if (not year % 4) , it will give you True in leap year! Because if 0 reminder will come then 0==0 will be True and not 0 will be True
https://code.sololearn.com/cssJxMhziikv/?ref=app
See this code , All the best!
+ 1
if year%400==0 or (year%4==0 and year%100!=0) : #leap year
+ 1
thank you
+ 1
sorry it has me set it up so the iser can plug a number in and find out if its leap year or not
+ 1
so how do infix it so it will work with any year
+ 1
Just write, int(input()) where I have written 2000