Question: Python. This question is about reading files and detecting end of file. The following code is to display a file's contents to the screen. The
Python. This question is about reading files and detecting end of file. The following code is to display a file's contents to the screen. The condition of the while loop is not set. I leave a question mark instead. Please select a correct condition to read files until the end of file.
# Open the file
filename inputEnter the filename:
in file openfilenamer
# Prime the loop by reading the first line
line infile.readline
# If the line exists, print it and read the next line.
while :
printline end
line infile.readline
# Close the file
infile.close
A line!
B line
C line eol
D line
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
