Question: Write a python function named airports() that takes one parameter which holds the name of a comma-separated values file. Each line in the file contains

Write a python function named airports() that takes one parameter which holds the name of a comma-separated values file. Each line in the file contains the following data, corresponding to a flight segment: Origin Airport Code, Destination Airport Code, Airline Code, Flight number. For example, three lines in the file might look like: DCA,ORD,AA, 1120 (translation: DC to Chicago, American flight 1120) BOS,ORD,UA, 1251 (translation: Boston to Chicago, United flight 1251) DCA,PHL,AA,5106 (translation: DC to Philadelphia, American flight 5106) Your function should open the file and use its data to build and return a dictionary that contains all Airline Codes that are listed in the file, along with the frequency with which they were listed. For example, if the line only consisted of the three lines above, the function would return the following dictionary: ['AA': 2, 'UA': 1}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
