Write a function to check whether a given date in DD/MM/YYYY format is valid or not


Topic: Write a function to check whether a given date in DD/MM/YYYY format is valid or not

Solution

def date_validation(inputdate: str):
    """
    function take input date in DD/MM/YYYY format and check its validation.
    """
    import datetime
    dd, mm, year = inputdate.split('/')
    isValidDate = True
    try :
        datetime.datetime(int(year),int(mm), int(dd))
    except ValueError : 
        isValidDate = False
    if(isValidDate):
        print ("Input Date is Valid")
    else:
        print ("Input Date is invalid")



List all Python Programs