Hello how would I get save.py reading and saving my text document. I have code for save.py but it doesn't work. Can someone please help fix it so that it will correctly save onto another text document. import save 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\t5) Save Song Playlist')         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()

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Hello how would I get save.py reading and saving my text document. I have code for save.py but it doesn't work. Can someone please help fix it so that it will correctly save onto another text document.

import save

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\t5) Save Song Playlist')
        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 == '5':
            print()
            save.save_playlist(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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education