Python - save/load files which of the four seems to be the problem? and on which
ID: 3910780 • Letter: P
Question
Python - save/load files
which of the four seems to be the problem? and on which line would I change to fix it
1l def saveList(myList, myFilename): outputFile = open(myfilen ame, "w") 3 for item in myList: 41 5 outputFile.close() 61 7l def loadList(myFilename): outputFile.write(item "n") 91 inputFile = open(myFilename, "r") 10 for line in inputFile: newL?st.append(line) 12 return newList Above are the definitions of a function that will save a list of strings to a file, and a function that will load a list from a file. However, they don't quite work as intended. Which of the following problems presently occurs? Every time the list is saved and then loaded, one item is lost because savelist) saves one too few items. Every time the list is saved and then loaded, one item is lost because loadList() loads one too few items. Every time the list is saved and then loaded, extra blank lines are added between every list item. Every time the list is saved and then loaded, any line breaks present are lost and the text is merged onto one line.Explanation / Answer
At line 4 everytime new item is added to the file blank line is also added to the file
so everytime file is saved and loaded extra blank lines are added between every list item so option 3 is answer where the problem occurs
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.