import os.path
# Check if a file exist, return True/False
os.path.exists("test.txt")
# Check if a directory exist, return True/False, for >= python3.4
import pathlib
pathlib.Path("test").exists()
Source:
https://www.guru99.com/python-check-if-file-exists.html