from os import path
path.exists('file_name') This phrase returns a bool value (True or False). A file ends with its file format, however a directory ends with its folder name.