- 1
which lines are indentation errors
import os def read_file(file): line = None if os.path.isfile(file): data = open(file.'r') while line != '': line = data.readline() print(line)
2 Respuestas
0
I don't think indentation error present in your code but you need to refactor your code as below. You need to run while loop only if file is present and opened.
import os
def read_file(file):
line = None
if os.path.isfile(file):
data = open(file.'r')
while line != '':
line = data.readline()
print(line)
+ 1
why do u think there are errors?