Convert US Date into EU Date[solved]
What is wrong with this program? How do I get its output in the format of 1/1/2024? Its output is coming in the format of 01/01/2024. https://www.sololearn.com/coach/75?ref=app from datetime import datetime def convert_date_to_eu_format(date_str): try: # Parse the input date string date = datetime.strptime(date_str, '%m/%d/%Y') # Convert it to EU format eu_date = date.strftime('%d/%m/%Y') return eu_date except ValueError: try: # If the first attempt fails, try parsing as month name date = datetime.strptime(date_str, '%B %d, %Y') eu_date = date.strftime('%d/%m/%Y') return eu_date except ValueError: return "Invalid date format. Please enter date in MM/DD/YYYY or Month Day, YYYY format." # User input input_date = input() # Convert the date and print the result print(" ", convert_date_to_eu_format(input_date)) Someone help me to fix this. Thanks in Advance