Question: # Given the stubs for the following function ss and the main program, complete the implementation. ## Finish the assert statements to properly ##assert
# Given the stubs for the following function ss and the main program, complete the implementation. ## Finish the assert statements to properly ##assert the result shown below (be careful ## with the types of the variables). def get_month(date_str): ****** if www paran: date_str (string) contains a date in the format "YYYY/MM/DD" (where YYYY corresponds to the four digits of a year, MM to the two digits of a month, etc.). The function validates the string in the following order: If the date is empty, return e. If the date does not have 2 slashes, return -1. Extract the months from the date: If the month does not contain only digits, return "M". Otherwise, return the month as a string. Examples: Calling the function with "2021/05/25" should return "05" as a string. An input of "2021/05" should return an integer -1. _name__"__main__": ### Write 3 additional assert statements assert get month("2021/05/25") = "05"
Step by Step Solution
There are 3 Steps involved in it
Completed implementation of the getmonth function along with the assert statement p... View full answer
Get step-by-step solutions from verified subject matter experts
