# date_converter.py
# Converts day month and year numbers into two date formats
# using string format or f string.
# by: Scott Gordon
defmain():# get the day month and year as numbers
day=int(input("Enter the day number: "))month=int(input("Enter the month number: "))year=int(input("Enter the year: "))date1=str(month)+"/"+str(day)+"/"+str(year)months=["January","February","March","April","May","June","July","August","September","October","November","December"]monthStr=months[month-1]date2=monthStr+""+str(day)+", "+str(year)# print("The date is", date1, "or", date2+".") # using string concatenation
# print("The date is {0} or {1}.".format(date1, date2)) # using string format method
print(f"The date is {date1} or {date2}.")# using f string
main()
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)