Question: Please answer in Python (no imports) Instructions: - Write a function that takes in a path to a file as a string and returns a

Please answer in Python (no imports)

Instructions: - Write a function that takes in a path to a file as a string and returns a dictionary. - The keys are the name of the cities and the values are lists with names of the people who were born that city. - Code is case sensitive ("Chicago" != "chicago", "New York" != "New York."). - If the file only contains the header line, return an empty dictionary.

Doctests: >>> city_of_birth('files/info_1.txt') {'Chicago': ['Rob'], 'New York': ['Ella'], 'New York.': ['Mary']} >>> city_of_birth('files/info_2.txt') {'Chicago': ['Rob'], 'London': ['Ezra'], 'Paris': \ ['Mary'], 'paris': ['Ron', 'Harry']} >>> city_of_birth('files/header.txt') {}

Example file: Name, City, DOB Rob, Chicago, 10/10/2010 Ella, New York, 04/09/1970 Mary, New York. , 01/01/2004

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!