Hello!
Put print() in each loop to see where it returns True.
For the year 2400, this will happen in the first loop because 2400 % 4 == 0 is True and will print that this year leap.
Change the conditions
Also, if one enter something that cannot be converted to in like text for example the script will stop with ValueError
Put print() in each loop to see where it returns True.
For the year 2400, this will happen in the first loop because 2400 % 4 == 0 is True and will print that this year leap.
Change the conditions
def get_year(): print("Please input year:") year = int(input()) return year def if_else(year): if year % 4 == 0 and year % 100 != 0: print("It's a leap year") elif year % 400 == 0 and year % 100 != 0: print("It's a leap year") elif (year % 100 == 0): print("It's not a leap year") else: print("There is an error") def main(): years = get_year() if_else(years)Or put
if year % 100 ==0:
on topAlso, if one enter something that cannot be converted to in like text for example the script will stop with ValueError