Introduction In this lab, you are writing a function slashes_to_written(date_list) that gets the list in the [MM, DD, YYYY] format and displays it in a written format. Note: we are using the US format for strings: //. For example, 01/02/2022 can be represented as ['01', '02', '2022'] represents January 2nd, 2022. Written Format slashes_to_written(["01", "01", "1970"]) must return "January 1, 1970" slashes_to_written(["02", "03", "2000"]) must return "February 3, 2000" slashes_to_written(["10", "15", "2022"]) must return "October 15, 2022" slashes_to_written(["12", "31", "2021"]) must return "December 31, 2021" Instructions Finish the slashes_to_written() function Use the dictionary month_names that maps months to their English names. month_names = { 1: "January", 2: "February", 3: "March" ... } Note: the month key in the dictionary is stored as an integer, however, in the list it is stored as a string in the MM format, e.g., "01". Also, pay attention how the day is represented in the list and how it is output. You do not need to check if the date in the date_list passed in is valid or not. You can assume it is valid. (In the real-life scenario you would, of course, call validate_date() to make sure it is valid, and only then call slashes_to_written(). You can assume that at this point the input is valid. ) Troubleshooting If you are getting a KeyError: '01' for "01" pay attention to what is the type of the keys stored 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. ;-)
Introduction In this lab, you are writing a function slashes_to_written(date_list) that gets the list in the [MM, DD, YYYY] format and displays it in a written format. Note: we are using the US format for strings: //. For example, 01/02/2022 can be represented as ['01', '02', '2022'] represents January 2nd, 2022. Written Format slashes_to_written(["01", "01", "1970"]) must return "January 1, 1970" slashes_to_written(["02", "03", "2000"]) must return "February 3, 2000" slashes_to_written(["10", "15", "2022"]) must return "October 15, 2022" slashes_to_written(["12", "31", "2021"]) must return "December 31, 2021" Instructions Finish the slashes_to_written() function Use the dictionary month_names that maps months to their English names. month_names = { 1: "January", 2: "February", 3: "March" ... } Note: the month key in the dictionary is stored as an integer, however, in the list it is stored as a string in the MM format, e.g., "01". Also, pay attention how the day is represented in the list and how it is output. You do not need to check if the date in the date_list passed in is valid or not. You can assume it is valid. (In the real-life scenario you would, of course, call validate_date() to make sure it is valid, and only then call slashes_to_written(). You can assume that at this point the input is valid. ) Troubleshooting If you are getting a KeyError: '01' for "01" pay attention to what is the type of the keys stored 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. ;-)
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18SA
Related questions
Question
100%
Introduction
In this lab, you are writing a function slashes_to_written(date_list) that gets the list in the [MM, DD, YYYY] format and displays it in a written format.
Note: we are using the US format for strings: <MM>/<DD>/<YEAR>. For example, 01/02/2022 can be represented as ['01', '02', '2022'] represents January 2nd, 2022.
Written Format
- slashes_to_written(["01", "01", "1970"]) must return "January 1, 1970"
- slashes_to_written(["02", "03", "2000"]) must return "February 3, 2000"
- slashes_to_written(["10", "15", "2022"]) must return "October 15, 2022"
- slashes_to_written(["12", "31", "2021"]) must return "December 31, 2021"
Instructions
- Finish the slashes_to_written() function
- Use the dictionary month_names that maps months to their English names.
month_names = { 1: "January", 2: "February", 3: "March" ... }
Note: the month key in the dictionary is stored as an integer, however, in the list it is stored as a string in the MM format, e.g., "01". Also, pay attention how the day is represented in the list and how it is output.
- You do not need to check if the date in the date_list passed in is valid or not. You can assume it is valid. (In the real-life scenario you would, of course, call validate_date() to make sure it is valid, and only then call slashes_to_written(). You can assume that at this point the input is valid. )
Troubleshooting
- If you are getting a KeyError: '01' for "01" pay attention to what is the type of the keys stored 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. ;-)
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 5 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning