Question: [Python] In the space below write a standalone function (not part of a class) called get_day_counts that does the following: 1) Takes in a single

[Python]

[Python] In the space below write a standalone function (not part of

In the space below write a standalone function (not part of a class) called get_day_counts that does the following: 1) Takes in a single parameter called lines with the lines from a file as a list of strings 2) Initializes day_dict to an empty dictionary 3) Uses a regular expression to find the day part of dates in the format MM/DD/YY or MM-DD-YY where MM is month, DD is the day, and YY is the year in the lines and uses day_dict to count the number of times each day appears. and 4) Returns a list of tuples (day count) sorted by count descending For example, get_day_counts(["02/04/20 12-30-19, 03/04/20, 08-20-30"]) returns [("04", 2), ("20", 1), ("30", 1)]. Run Load History Show CodeLens 3 1 import re 2 def get_day_counts(lines): # your code here 4 5 lines = ["02/04/20 12-30-19", "03/04/20", "08-20-30"] 6 print(get_day_counts(lines)) 7

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 Databases Questions!