Question: Task 4 : The Time HeistTM ( 4 0 % of grade ) Create a function called dateRange which accepts three required positional parameters: start

Task 4: The Time HeistTM (40% of grade)
Create a function called dateRange which accepts three required positional parameters:
start (str), end (str), and step (int).
o This function will operate similarly to the built-in range function, but it will produce a list
of dates instead of integers.
o Both start and end will be strings in the format YYYY-MM-DD. Use the
string.split method and int casts to convert both strings into separate year,
month, and day components.
o Call your offset function in a loop to build a list of each date starting with start,
moving in step increments, up to and excluding end.
o This function should return the list of date strings in the format YYYY-MM-DD.
o Hint: to zero-pad the month and the day when filling your list (for example, to record 06
instead of 6), use an f-string such as the following (assuming year, month, and day are all defined variables):
f"{year}-{month:02d}-{day:02d}"
Some example executions are provided below. More may be tested in Vocareum. Example execution 5:
>>> dateRange("2024-07-31","2025-01-31",31)['2024-07-31',
'2024-08-31','2024-10-01','2024-11-01','2024-12-02','2025-01-02']
>>> dateRange("1984-08-02","1983-12-01",-31)['1984-08-02',
'1984-07-02','1984-06-01','1984-05-01','1984-03-31','1984-02-29','1984-01-29','1983-12-29']

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!