Question: * * PYTHON * * Write a program that first reads in the name of an input file and then reads the input file using
PYTHON
Write a program that first reads in the name of an input file and then reads the input file using the file.readlines method. The input file
contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the input
file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values since multiple shows could have the
same number of seasons
Sort the dictionary by key least to greatest and output the results to a file named outputkeys.txt separating multiple TV shows
associated with the same key with a semicolon Next, sort the dictionary by values alphabetical order and output the results to a file
named outputtitles.txt
Ex: If the input is:
filel.txt
and the contents of filetxt are:
the file outputkeys.txt should contain:
and the file outputtitles.txt should contain:
Note: There is a newline at the end of each output file, and filetxt is available to download.
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
