Учитывая то, что вы пытаетесь сделать, я считаю, что это один из способов сделать это, комбинируя цикл for
для элементов, которые вы передаете в функцию (в формате списка), с указанными вами условиями if-elif-else
.
years = ["25", "1955", "2000", "1581", "1321", "1285", "4365", "4", "1432", "3423", "9570"]
def isLeap(years):
for i in years:
if int(i) >= 1583:
print(i, "Is a Gregorian Calendar Year.")
elif int(i) < 1583:
print(i, "Is not a Gregorian Calendar Year.")
elif int(i) % 400 == 0 or int(years[i]) % 4 == 0:
print(i, "Is a Leap Year.")
elif int(i) % 400 == 1 or int(years[i]) % 4 == 1:
print(i, "Is NOT a Leap Year.")
else:
print("Test cannot be performed.")
isLeap(years)
Выход:
25 Is not a Gregorian Calendar Year.
1955 Is a Gregorian Calendar Year.
2000 Is a Gregorian Calendar Year.
1581 Is not a Gregorian Calendar Year.
1321 Is not a Gregorian Calendar Year.
1285 Is not a Gregorian Calendar Year.
4365 Is a Gregorian Calendar Year.
4 Is not a Gregorian Calendar Year.
1432 Is not a Gregorian Calendar Year.
3423 Is a Gregorian Calendar Year.
9570 Is a Gregorian Calendar Year.