str.capitalize(): returns a copy of the string with only its first character capitalized.
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] def valid_month(month): if month: cap_month = month.capitalize() if cap_month in months: return cap_month
use dictionary to restrict only three character.
month_abbvs = dic((m[:3].lower(), m) for m in months) def valid_month(month): if month: short_month = month[:3].lower() return month_abbvs.get(short_month)
checking day
def valid_day(day): if day and day.isdigit(): day = int(day) if day > 0 and <= 31: return day