1def leap_year(year):
2 if year % 400 == 0:
3 return True
4 if year % 100 == 0:
5 return False
6 if year % 4 == 0:
7 return True
8 return False
9
10def days_in_month(month, year):
11 if month in {1, 3, 5, 7, 8, 10, 12}:
12 return 31
13 if month == 2:
14 if leap_year(year):
15 return 29
16 return 28
17 return 30
18
19print(days_in_month(2, 2016)) # 29
20