Is this a wrong way of finding the leap years?

90 Views Asked by At

I am a beginner, learning Python from "Python Programming MOOC 2022". They are asking me to write a code which asks for a year and then says whether it is a leap year or not. The problem is that when I write the code, the website says its wrong, as it has an infinite loop.

# Write your solution here
y=int(input("Please type in a year:"))
if y%4==0:
    if y%100==0 :
        if y%400==0:
            print("That year is a leap year.")
        else:
            print("That year is not a leap year.")
    else:
        print("That year is a leap year.")
else:
    print("That year is not a leap year.")

I cant really understand where the infinite loop is. I'll be really thankful if you tell me what's wrong with this code so that I can fix it.

I ran this code on some online ides and it worked without any problem. I cant understand whether I am wrong or the website is facing some issues...

0

There are 0 best solutions below