Top Research Professionals
The research experts and assignment help team consists exclusively of highly qualified graduate writers, each professional with in-depth subject matter expertise and significant experience in custom academic writing.
For similar papers and sample answers; with a few clicks, Order your research paper, thesis, dissertation writing and other assignment help services
Posted: April 13th, 2023
student
I’m working on a python question and need support to help me understand better.
Write a function that takes the name of an input file as a parameter and then reads the input file. The input file contains an unsorted list of a 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). Finally, the function returns the dictionary. (Note: The keys in the dictionary are integers and not string)
Input: (Download the input file ‘input.txt’ from here) :
Content of input.txt:
20
Gunsmoke
30
The Simpsons
10
Will & Grace
14
Dallas
20
Law & Order
12
Murder, She Wrote
Expected output:
The returned dictionary for the file input.txt should be
{20: [‘Gunsmoke’,’Law & Order’],30: [‘The Simpsons’], 10: [‘Will & Grade’], 14: [‘Dallas’], 12: [‘Murder, She Wrote’]}
Hints (Not the complete solution or steps):
1. Once you have opened the file, which file read method will make the rest of the task easier? read() or readlines()?
2. Think about converting the lines of the file into a list of strings. Do you need to strip anything from the items on the list?
3. Do you see any pattern for the location of the keys in this list?
4. The values should be stored as a list for each key. Do you need to check if a value for a key already exists in the dictionary? If so what should you do?
Requirements:
-research paper writing servic
We prioritize delivering top quality work sought by college students.
The research experts and assignment help team consists exclusively of highly qualified graduate writers, each professional with in-depth subject matter expertise and significant experience in custom academic writing.
Our custom writing services maintain the highest quality while remaining affordable for students. Our pricing for research papers, theses, and dissertations is not only fair considering the superior quality but also competitive with other writing services.
We guarantee plagiarism-free, human-written content. Every product is assured to be original and not AI-generated. Our writers, tutors and editors are research experts who ensures the right formating and citation sytles are followed. To note, all the final drafts undergo rigorous plagiarism checks before delivery for submission to ensure authenticity for our valued customers.
When you decide to place an order with Dissertation Help, here is what happens: