QUESTION IMAGE
Question
complete the code.
fruitpairs = apple, 0.85,banana,0.90,peach,1.50
outfile = open(\fruitnew.txt\,\w\)
for item in fruitpairs:
line = item0 + , + str(item1) + \
outfile.write(line)
outfile ()
Step1: Identify the missing part
The code is opening a file for writing and iterating through a list to write data to the file. After all writing operations are done, the file needs to be closed.
Step2: Determine the closing operation
In Python, to close a file that was opened using the open function, the close method of the file - object is called.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
close()