Question: Write a function called count_in_area_code that accepts two parameters, a dictionary from names (strings) to phone numbers (strings) and an area code (as a

Write a function called count_in_area_code that accepts two parameters, a dictionary from

Write a function called count_in_area_code that accepts two parameters, a dictionary from names (strings) to phone numbers (strings) and an area code (as a string), and returns how many unique phone numbers in the map use that area code. For example, if a map m contains these pairs: {Marty=206-685-2181, Rick-520-206-6126, Beekto-206-685-2181, Jenny-253-867-5309, Stuart-206-685-9138, DirecTV-800-494-4388, Bob-206-685-9138, Benson-206-616-1246, Hottline-900-520-2767} The call of count_in_area_code (m, "206") should return 3, because there are 3 unique phone numbers that use the 206 area code: Marty/Beekto's number of "206-685-2181", Stuart/Bob's number of "206-685- 9138", and Benson's number of "206-616-1246". You may assume that every phone number value string in the dictionary will begin with a 3-digit numeric area code, and that the area code string passed will be a numeric string exactly 3 characters in length. If the dictionary is empty or contains no phone numbers with the given area code, your function should return 0. You may create one collection (list, dictionary, set) of your choice as auxiliary storage to solve this problem. You can have as many simple variables as you like. You should not modify the contents of the dictionary passed to your function.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed ... View full answer

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