Computer Science > Lab Experiment > Michigan State University - CSE CSE231lab09b.py (All)

Michigan State University - CSE CSE231lab09b.py

Document Content and Description Below

# Define the function to create a dictionary #and store the values as dictionaries and sets def build_map(continent_file, city_file): Data_map = {} # read the continents.txt file and #create the ... dictionary of continents and countries continent_country_content = continent_file.readlines() continent_country_content = continent_country_content[1:] #Read each line from the continent_file for line in continent_country_content: # Remove the header of the file continent_list = line.strip().split('\t',1) continent = continent_list[0].strip() country = continent_list[1].strip() #check whether continents exist in the dictionary #or not if continent not in Data_map.keys(): Data_map[continent] = {country : set()} elif country not in Data_map[continent].keys(): Data_map[continent][country] =set() # read the cities.txt file and add cities to the countries #included in the dictionary country_city_content = city_file.readlines() country_city_content = country_city_content[1:] for line in country_city_content: # Remove the header of the file country_list = line.strip().split('\t',1) country = country_list[0].strip() [Show More]

Last updated: 1 year ago

Preview 1 out of 3 pages

Add to cart

Instant download

document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Add to cart

Instant download

Reviews( 0 )

$5.00

Add to cart

Instant download

Can't find what you want? Try our AI powered Search

OR

REQUEST DOCUMENT
73
0

Document information


Connected school, study & course


About the document


Uploaded On

Mar 29, 2021

Number of pages

3

Written in

Seller


seller-icon
Expert Tutor

Member since 3 years

57 Documents Sold


Additional information

This document has been written for:

Uploaded

Mar 29, 2021

Downloads

 0

Views

 73

Document Keyword Tags

What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Browsegrades · High quality services·