Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that first reads in the name of an input file and then reads the input file using the file readlines 0 method.

image text in transcribed
image text in transcribed
Write a program that first reads in the name of an input file and then reads the input file using the file readlines 0 method. The input file contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the cantents 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 (greatest to least) and output the results to a file named output keys.txt Separate multiple TV shows associated with the same key with a semicolon (i), ordering by appearance in the input file. Next, sort the dictionary by values (in reverse alphabetical order), and output the resuls to a file named output titles.txt Ex: if the input is: tilel, txt and the contents of file1.txt are: 20 Sunamoke 30 The simpsond 10 Wi11 \& Grace: 14. Da1laa 20 Lak 6 order 12 Kurder, she wrote the file output keys.txt should contain: 20: Gunsmoke: Law \& Oxder 30: The simpsons and the file outputtities. txt should contain: ballas Gunsmoke Law 6 Order Murder, She Wrote The simpaona will \& Grace Note End each output file with a newine, and file1.txt is available to download

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions