At the beginning of a Python loop, I want the code to test if a certain file exists in the current folder, and if it doesn’t, I want it to jump out and restart the loop with the next value.
I have done this before when trying to remove a file:
try:
os.remove('file.txt')
except os.error:
pass
Would I need to do something similar? But instead of “pass”, I would “continue”?
Obviously I am not trying to remove a file now, I just want to see if it exists. Thank you!
Use
for checking if your file exists.