• Why doesn't this code work? Looks right :)

Question related to mission Convert Date

 
def convert_date(date: str) -> str:
    date = date[::-1]
    new_date = date.replace("/","-")

    from datetime import datetime 
    try:
        datetime.strptime(new_date,"%d-%m-%Y")
        return new_date
    except ValueError:
        return "Error.Invalid date."