In PYTHON,
Write a function formatLongDate that will accept a date in the form mm/dd/yy as a string argument. Your program should take the string apart (hint: use an appropriate string function) into month, day and year variables. Return the date in the long format (e.g. 09/30/05 would be output as September 30, 2005). You may assume all years yy are in the 21st century. For instance:
>>> formatLongDate("09/05/99")
September 5, 2099
September 5, 2099
def formatLongDate(s): lst = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] values = s.split("/") month = lst[int(values[0])-1] day = values[1] year = "20"+values[2] return month+" "+day+", "+year # Testing print(formatLongDate("09/05/99"))
September 05, 2099
Get Answers For Free
Most questions answered within 1 hours.