Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please, help! I need to write a Python program to solve the following problem: I

ID: 3766114 • Letter: P

Question

Please, help!

I need to write a Python program to solve the following problem:

Input a date in numeric format from the user e.g. mm/dd/yy.

Examine the month entered by the user. If it is larger than 12 or smaller than 1 issue an error message and ask for input again.

Perform similar validation tests for the date and year. Year must not be less than 2013 or larger than 2013. In addition, the year must only be two digits long.

Once all input has been validated, output the string in long date format. Thus a string that was input as 06/01/13 will be output as June 1, 2013.

Explanation / Answer

def validateDate(date):
# Not accounting for leap year
validdt = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
date = date.split('/')
try:
mo = int(date[0])
day = int(date[1])
yr = int(date[2])
if day > 0 and mo > 0 and day <= validdt[mo-1]:
return True
return False
except:
return False

def tstit():
print('01/31/19: ', validateDate('01/31/19'))
print('13/05/14: ', validateDate('13/05/14'))
print('12/31/14: ', validateDate('12/31/14'))
print('12/32/14: ', validateDate('12/32/14'))
print('01/01/01: ', validateDate('01/01/01'))
print('01/00/01: ', validateDate('01/00/01'))
print('00/01/01: ', validateDate('00/01/01'))
print('02/28/01: ', validateDate('02/28/01'))
print('02/29/01: ', validateDate('02/29/01'))

tstit()