Question: Continuing on from the previous question, consider a list of names and phone numbers: [paul:64-07-826-5671, peter:64-06-3220-990, apple:64-03-304-2567, may:64-09-520-1990, david:64-09-255-2301,james:64-07-826-1236, nicole:64-09-274-1908] Write a function named get_phones_by_area_code(phones_list,

Continuing on from the previous question, consider a list of names and phone numbers:

["paul:64-07-826-5671", "peter:64-06-3220-990", "apple:64-03-304-2567", "may:64-09-520-1990", "david:64-09-255-2301","james:64-07-826-1236", "nicole:64-09-274-1908"]

Write a function named get_phones_by_area_code(phones_list, area_code) that takes a list of names and phones information and an area code as parameters and returns a list of tuples. Each tuple contains a name and the corresponding phone number where the phone number is in the parameter area code.

Note: you can assume that the get_location_information() is given and the parameter list is not an empty list and the parameter area_code is not empty and valid.

For example:

Test Result
phone_directory = ["paul:64-07-826-5671", "peter:64-06-3220-990", "apple:64-03-304-2567", "may:64-09-520-1990", "david:64-09-255-2301","james:64-07-826-1236", "nicole:64-09-274-1908"] print(get_phones_by_area_code(phone_directory, '09')) 
[('may', '64-09-520-1990'), ('david', '64-09-255-2301'), ('nicole', '64-09-274-1908')] 
phone_directory = ["paul:64-07-826-5671", "peter:64-06-3220-990", "apple:64-03-304-2567", "may:64-09-520-1990", "david:64-09-255-2301", "james:64-07-826-1236", "nicole:64-09-274-1908"] print(get_phones_by_area_code(phone_directory, '03'))
[('apple', '64-03-304-2567')]

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!