Checking File Or Directory Existence
Mon 10 August 2026
import os
print(os.path.exists("data.txt")) # True or False
print(os.path.isfile("data.txt")) # Checks file
print(os.path.isdir("new_folder")) # Checks directory
False
False
True
Score: 10
Category: chapter12_file_handling