Question: python In this lab, you are writing a function get_written_date (date_list) that takes as a parameter a list of strings in the [MM, DD, YYYY]

![DD, YYYY] format and returns the resulting date (in the US format)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3ccc4f0468_70066f3ccc487ea5.jpg)


In this lab, you are writing a function get_written_date (date_list) that takes as a parameter a list of strings in the [MM, DD, YYYY] format and returns the resulting date (in the US format) as a string. Note: we are using the US format for strings: MM>/DD>/YEAR> For example, 01/02/2022 can be represented as [' 01 ', ' 02 ', '2022' 1, which represents January 2 nd, 2022 Test Your Code Instructions Use the dictionary month_names that maps months to their English names. month_names 1 1: "January", 2: "Eebruary", 3: "March" Note the month key in the dictionary is stored as an integer, however, in the input list it is stored as a string in the Man format, e.g. " 01 ". Also, pay attention how the day is represented in the list and how it is supposed to be output. - You may assume that the dates in date_list is a valid date. Troubleshooting - If you are getting a KeyError: "01' for "01" pay attention to the type of the keys in the dictionary (See the Note above -)) - If you are having trouble converting a " 01 " into just 1 , think how you would turn just " 1 " into an integer. -) What if you use the same mechanism with " 01 "? The function ... month_names ={ 1: "January", 2: "February", 3: "March", 4: "April", 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December", 3 \# if the input type is not a list or list is empty then return None if type(date_list) 1= list or len(date_list) =0 : return None \# going through all the elements of the list for ele in date.list: \# if type of any element is not a string then return None if type(ele) 1= str: return None \# if we have a valid list then get the month and the day as integers and the year as it is month = int(date_list [0]) day = int(date.list[1]) \#getting the day as an integer will automatically remove any leading os year = date _list [2] \# going through all the elements of the list for ele in date_list: \# if type of any element is not a string then return None if type(ele) I=str: return None \# if we have a valid list then get the month and the day as integers and the year as it is month = int (date_list [0]) day = int(date_list[1]) \# getting the day as an integer will automatically remove any leading os year = date.list [2] \# getting the month equivalent string from the month_names \# we converted month to an integer above because the keys in the dictionary are integers as well. So w month_name = month_names [month] \# generating the date string using the f-string date = f{ month_name\} \{day\}, \{year\}' * returning the generated date return date if _name_. ". "main__": assert get_written_date(["01", "02", "2022"]) = 'January 2,2022 assert get_written_date(["01", "12", "1970"]) = 'January 12,1970 assert get_written_date(["04", "14", "2020" ] ) = "April 14, 2020 ' assert get_written_date(["06", "19", "2000"]) = 'June 19, 2000 ' \# printing the function returned values print(get_written_date([ 01 ", "02", "2022"])) print(get_written_date(["01", "12", "1970"])) print(get_written_date(["04", "14", "2020"])) print(get_written_date(["06", "19", "2000"])) Latest submission - Invalid date on Invalid date Total score: 5/10 Only show failing tests Download this submission 2.Unit test 2 0/5 Random dates We got a return value Test feedback None instead of: May 32, 1671
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
