def create_dict_by_region(directory_path, number_of_regions): """ Given a directory of files with name of the form "regionN.txt" where goes from 1 to number_of_regions. Create two dictionaries: - dict1: a dictionary where the keys are the region number and the value is the name of that region. - dict2: a dictionary where the keys are the names of the regions and the value is a list of the states in that region. :param directory_path: the directory where these files are :param: number_of_regions: the number of region files we expect to find in the directory :return: tuple of the two dictionaries dict1, dict2 """ REGIONS FILES: REGION1 FILE: North PA NY REGION 2 FILE: Middle VA MD NC REGION 3 FILE: South GA AL REGION 4 File: West TX NM OK CA
def create_dict_by_region(directory_path, number_of_regions):
"""
Given a directory of files with name of the form "regionN.txt" where goes from
1 to number_of_regions.
Create two dictionaries:
- dict1: a dictionary where the keys are the region number and the value is the name
of that region.
- dict2: a dictionary where the keys are the names of the regions and the value is
a list of the states in that region.
:param directory_path: the directory where these files are
:param: number_of_regions: the number of region files we expect to find in the directory
:return: tuple of the two dictionaries dict1, dict2
"""
REGIONS FILES:
REGION1 FILE:
North
PA
NY
REGION 2 FILE:
Middle VA MD NC
REGION 3 FILE:
South GA AL
REGION 4 File:
West TX NM OK CA
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images