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
Step: 1
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