I am trying to print out the full text of a text file. But if that text file does not exist, I want it to print that it does not exist, otherwise it wont let the rest of the code work.
Printing out only the text files works
for x in ABC:
print(f"{x}:")
with open("./" + x + "/Log.txt") as f:
print(f.read())
However, when I am trying to see if that file is found, I get an error. This is how I tried to do it (it is wrong)
for x in ABC:
print(f"{x}:")
with open("./" + x + "/Log.txt") as f:
if f.empty:
print("No files found.")
else:
print(f.read())