Hello. How would I get def automated to read the opened text document and make a playlist with the specified time and genre. Example I want to randomly select blues songs that total as close to 20 minutes as possible. import save def automated(filename):     try:         print(filename)     except FileNotFoundError:         print('Document not found.') def main():     filename = ''     print('-'*45)     choice = ''     while choice.upper() !='Q':         print()         if filename != '': print('Current file opened:', filename)         print('0) Choose a file to open\t1) Automated song choice')         print('Q) Quit')         choice=input('Enter a choice: ')         if choice == '0':             print()             filename = input('Enter file name: ')            rfile =open(filename,'r')             line_list =rfile.read()             for word in line_list:                 words_list=word.split(' ')             print(line_list)             print(f"File {filename} opened.")         elif choice == '1':             print()             automated(filename)         elif choice.upper() == 'Q':             print("Program complete.")         else:             print('Invalid choice.') main() contents of imported save.py def save_playlist(filename):     words_list = []     line_list -[]     savefilename =input('Enter save file name:')     savefile=open(savefilename,'w')     for index in range(len(line_list)):         line_list[index] =line_list[index].rstrip('\n')         print(line_list)         for word in line_list:                        words_list=word.split(' ')     line_list.sort()     for item in line_list:         savefile.write(item + '\n')         savefile.close() contents of start.txt text document Alternative Bastille Pompeii 3:34 Happier 3:34 Of The Night 3:33 Panic! At The Disco I Write Sins Not Tragedies 3:06 Nine in the Afternoon 3:11 High Hopes 3:10 Blues Tab Benoit Nothing Takes The Place Of You 4:01 For What It's Worth 5:17 Shelter Me 5:05 Joe Bonamassa I'll Take Care Of You 5:41 The Heart That Never Waits 5:51 Notches 7:04 Robert Cray Right Next Door (Because of Me) 4:21 Smoking Gun 4:05 This Man 5:06

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Hello. How would I get def automated to read the opened text document and make a playlist with the specified time and genre. Example I want to randomly select blues songs that total as close to 20 minutes as possible.

import save


def automated(filename):
    try:

        print(filename)
    except FileNotFoundError:
        print('Document not found.')

def main():
    filename = ''
    print('-'*45)
    choice = ''
    while choice.upper() !='Q':
        print()
        if filename != '': print('Current file opened:', filename)
        print('0) Choose a file to open\t1) Automated song choice')
        print('Q) Quit')
        choice=input('Enter a choice: ')
        if choice == '0':
            print()
            filename = input('Enter file name: ')
           rfile =open(filename,'r')
            line_list =rfile.read()
            for word in line_list:
                words_list=word.split(' ')
            print(line_list)
            print(f"File {filename} opened.")
        elif choice == '1':
            print()
            automated(filename)
        elif choice.upper() == 'Q':
            print("Program complete.")
        else:
            print('Invalid choice.')

main()

contents of imported save.py

def save_playlist(filename):
    words_list = []
    line_list -[]
    savefilename =input('Enter save file name:')
    savefile=open(savefilename,'w')

    for index in range(len(line_list)):
        line_list[index] =line_list[index].rstrip('\n')
        print(line_list)
        for word in line_list:
          
            words_list=word.split(' ')
    line_list.sort()

    for item in line_list:
        savefile.write(item + '\n')
        savefile.close()

contents of start.txt text document

Alternative
Bastille
Pompeii
3:34
Happier
3:34
Of The Night
3:33
Panic! At The Disco
I Write Sins Not Tragedies
3:06
Nine in the Afternoon
3:11
High Hopes
3:10

Blues
Tab Benoit
Nothing Takes The Place Of You
4:01
For What It's Worth
5:17
Shelter Me
5:05
Joe Bonamassa
I'll Take Care Of You
5:41
The Heart That Never Waits
5:51
Notches
7:04
Robert Cray
Right Next Door (Because of Me)
4:21
Smoking Gun
4:05
This Man
5:06

Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY