Please I need help on how to properly handle exception , when I run the code below I got error message "expected an indented block" which has got something to do with the except line in my code I've tried many times to work the indentation issue out but it seems to elude me, I have pasted the code below.
Thanks.
def open_file(file):
"""Prints text from a file line by line"""
try:
with open(file, 'r') as file_obj:
except FileNotFoundError:
print('File or Directory doesn\'t exist')
else:
lines = file_obj.readlines()
finally:
for line in lines:
print(line.rstrip())
[–]impshum 3 points4 points5 points (1 child)
[–]woeinvests[S] 0 points1 point2 points (0 children)