Цель — написать функцию, которая возвращает количество дней в любом заданном месяц года (високосный или другой).
Код: Выделить всё
def is_leap_year(year):
if year % 4 == 0:
return True
else:
return False
def days_in_month(year, month):
month_day = [31,28,31,30,31,30,31,31,30,31,30,31]
if month > 12 or month < 1:
return None , "Please choose a number between and including 1 and 12"
if is_leap_year(False):
return month_day[month - 1]
if is_leap_year(True) and month == 2:
month_day[1] == 29
return month_day[month - 1]
print(is_leap_year(2024))
print(days_in_month(2024,2))
Код: Выделить всё
True
None
Извиняюсь, если это простой вопрос, я новичок в Python.
Подробнее здесь: https://stackoverflow.com/questions/787 ... cluding-le