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 = input(Enter the filename: ')
in _file = open(filename,'r')
# Prime the loop by reading the first line
line = in_file.readline()
# If the line exists, print it and read the next line.
while ?:
print(line, end="")
line = in_file.readline()
# Close the file
in_file.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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!