Question: Create a function, temp _ dictionary ( ) that can read from a file name passed in as a parameter. The file passed in contains
Create a function, tempdictionary that can read from a file name passed in as a parameter. The file passed in contains individual temperatures in degrees Fahrenheit from cities around the world on a given day. Your job is to read the file and create a dictionary from the data. Steps Create a function called tempdictionary that takes in a file name as a parameter. Read the first line, which tells you the number of citytemperature pairs in the file. The structure of the file can be seen in the example file, temperaturesexample.txt Read the rest of the file. The information for one city is on two lines. The first line is a city name, the second line is that city's temperature, and so on Create a dictionary, storing the city name as a key and the temperature as its value. Be sure to return your dictionary!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
