Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# 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

# 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

Step: 1

Completed implementation of the getmonth function along with the assert statement p... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Auditing a business risk appraoch

Authors: larry e. rittenberg, bradley j. schwieger, karla m. johnston

6th Edition

9780324645095, 324645090, 978-0324375589

More Books

Students also viewed these Programming questions