Learning to code and this is one of the first projects I’m attempting it calculates if the year you enter is a leap year or not. This program seems to run fine however one of the test inputs ‘1900’ doesn’t return anything. Could someone explain why? Really struggling to figure this one out on my own. All the other test inputs I tried returned the expected result. Cheers 🙂
year = int(input("Enter year: "))
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print("Leap year")
else:
("Not leap year")
else:
print("Leap year")
else:
print("Not leap year")
New contributor
cameron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1