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: 2 years ago

Preview 1 out of 3 pages

Buy Now

Instant download

We Accept:

We Accept
document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

We Accept

Reviews( 0 )

$5.00

Buy Now

We Accept:

We Accept

Instant download

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

103
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 4 years

58 Documents Sold

Reviews Received
6
2
0
0
3
Additional information

This document has been written for:

Uploaded

Mar 29, 2021

Downloads

 0

Views

 103

Document Keyword Tags


$5.00
What is Scholarfriends

In Scholarfriends, 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 © Scholarfriends · High quality services·