Python program to validate a Gregorian date


Topic: Python program to validate a Gregorian date

Solution

def check_date(m, d, y):
    import datetime
    try:
        m, d, y = map(int, (m, d, y))
        datetime.date(y, m, d)
        return True
    except ValueError:
        return False
print(check_date(11, 11, 2002))
print(check_date('11', '11', '2002'))
print(check_date(13, 11, 2002))



List all Python Programs