Conditionals, Loops
def days_in_month(date):
"""How many days are there in a month?"""
# START SOLUTION
month, year = date.split()
month = int(month)
year = int(year)
# Account for February
if month == 2:
if is_leap_year(year):
return 29
else:
return 28
if month in {1, 3, 5, 7, 8, 10, 12}:
return 31
if month in {4, 6, 9, 11}:
return 30
Month Names
Consider how you would handle receiving the months as words (like “January”) instead of as numbers. Would the solution need to change?