Asked by Jordan12804
Sorting TV shows (dictionaries and lists) 7.9 LAB: Sorting TV Shows...
Sorting TV shows (dictionaries and lists)
Image transcription text
7.9 LAB: Sorting TV Shows (dictionaries and lists) 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 output_keys.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 output_titles.txt. Ex: If the input is: filel . txt and the contents of file 1.txt are: 20 Gunsmoke 30 The Simpsons 10 Will & Grace 14 Dallas 20 Law & Order 12 Murder, She Wrote the file output_keys.txt should contain: 10: Will & Grace 12: Murder, She Wrote
Answered by poovin91
Unlock full access to Course Hero
Explore over 16 million step-by-step answers from our library
Subscribe to view answerce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolornec facilisacinia pulvinarf, consectetur adipiscing elit. Nam lacinia puur laoreet. Nam risus ante, dapibus a molestie consequat, ultricecefng elit. Nam lacinia pulvinar tortor nec facilisis.acinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet., ultrices ac magna. Fusce dui lectus, congue vel laoreetsqueonec aliqusce dui lce dui lectus, congue velce dui lectus, congunte,ipiscing elit. Naicia pulvinarfa molestie consequat, ultrices ac magna. Fusce dui lectus, congue0ur laoreetusceonecce, ultrices ac magna. Fusce dui lectus, congue vel laoreetfur laoreetusceonecces ante, dapibus a molestie consequafacilisis. Pellentesque dapibus efficitur laoreet. Nam riec aliquet. Lorem ipsum dolor situtrices ac msugueficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictuonecitur laoreet. Nam risus ante, dapibus a molestieusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsumFusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec alifficitur laentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestielestie consequat, ultrices ac magna. Fuscerem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Loremnec facilisis. Pellentesque dapibus efficitur laoreet. Naiciscing elitfor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risusipiscing elitipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus effionec aliquet. Loac, dictum
pulvcongue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet,
Answered by atchyutk8
Unlock full access to Course Hero
Explore over 16 million step-by-step answers from our library
Subscribe to view answersce dui lectus, congue vel laoree
gue vel laoreet ac, dictu
ce dui lectus, congue vel laoreet ac, dictum vitae od
at, ultrices ac magna. Fusce d
fficitur laoreet. Nam risus an
a molesti
ng elit. Nam lacinia pulvinar t
dictum vi
, dictum vita
m ipsum dolor sit amet, consecte
a molesti