Question
Extract the timestamp and the phone number from each specific line into separate variables (e.g., timestamp and phone_number). For example, you can use the split
Extract the timestamp and the phone number from each specific line into separate variables (e.g., timestamp and phone_number). For example, you can use the split method to separate the line into the two constituents (carefully choose where to split). You can assign the constituents in a single statement just like this: x, y = 'Hello, World'.split(', ') # `x` is assigned with 'Hello' # `y` with 'World' Implement an if statement that checks the phone_number's area code and evaluates to True if the area code matches the argument provided to the area_code parameter (else it evaluates to False). Validate your work by printing the lines to the terminal
You should see a similar output as before. However, there should only be the phone numbers with the area code matching the one provided in the argument.
Next, parse the timestamp into a datetime object. This will enable you to easily determine if the call happened between certain hours in a day. You can also refer to the following example
Modify the if statement to also check if the phone call happened between the hour of the day indicated by the start argument (included) and before the hour indicated by the end argument (not included).
Validate your work by printing the lines to the terminal.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the Python code that addresses the requirements Python import datetime def extractandf...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started