Please write in python! Finish the date_string function m = {1: (\"January\", 31
ID: 3662010 • Letter: P
Question
Please write in python!
Finish the date_string function
m = {1: ("January", 31) , 2: ("February", 28), 3: ("March", 31),
4: ("April", 30), 5: ("May", 31), 6: ("June", 30), 7:("July", 31),
8: ("August", 31), 9: ("September", 30), 10:("October", 31),
11: ("November", 30), 12:("December", 31)}
def date_string(day, month, year):
# Return “February 26, 2015” if day = 26, month = 2, year = 2015
#===== Your code goes here ===========================================
#=================================================================
# You may not alter the following code at all - all work must be above in the
# date_string function!
year = int(input("Please enter year: "))
month = int(input("Please enter month: "))
day = int(input("Please enter day: "))
try:
print(date_string(day, month, year))
except ValueError as e:
print (e)
Explanation / Answer
the code inside #=======Your code==========
x=m.get(month)
x.split(',' , 1)
res=x[0]
result=x[0]+" "+day+","+year
return result