Getting syntax error for the following line trying to use assert to test.
#test is_valid_date for April 4, 2014 and Januarary 3, 2012
print assert(is_valid_date(2014,4,4))
print assert(is_valid_date(2012,1,3))
Shouldn't the assert return true for the above if the function is_valid_date
returns true?
Here is the actual is_valid_date
implementation.
def is_valid_date(year, month, day):
"""
Inputs:
year - an integer representing the year
month - an integer representing the month
day - an integer representing the day
Returns:
True if year-month-day is a valid date and
False otherwise
"""
if year > datetime.MINYEAR and year < datetime.MAXYEAR:
if month >= 1 and month <= 12:
d = days_in_month(year, month)
if day >= 1 and day <= d:
return True
return False