Skip to content

Commit 4883208

Browse files
committed
change month_days to smallest func
1 parent a0f803b commit 4883208

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

projects/Calculate_age/calculate.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ def judge_leap_year(year):
1212

1313
# returns the number of days in each month
1414
def month_days(month, leap_year):
15-
if month == 1 or month == 3 or month == 5 or month == 7:
15+
if month in [1, 3, 5, 7, 8, 10, 12]:
1616
return 31
17-
elif month == 8 or month == 10 or month == 12:
18-
return 31
19-
elif month == 4 or month == 6 or month == 9 or month == 11:
17+
elif month in [4, 6, 9, 11]:
2018
return 30
2119
elif month == 2 and leap_year:
2220
return 29

0 commit comments

Comments
 (0)