Date Printer
Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the form March 12, 2012.
Date Printer Program Code:
def formatDate(dateString):
# Split the date string into month, day, and year
month, day, year = date_string.split('/')
# Create a list of month names
month_names = ['January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
# Convert the month string to an integer and get the corresponding month name
month_name = month_names[int(month) - 1]
# Print the formatted date
print(f"{month_name} {day}, {year}")
# Get the date string from the user
dateString = input("Enter a date (mm/dd/yyyy): ")
# Format and print the date
formatDate(dateString)
Executed Output:
Enter a date (mm/dd/yyyy): 05/15/2023
May 15, 2023