Source Code:
(back to article)
import os # Get a list of all files and directories in the current directory files_and_directories = os.listdir() # Check if "myfile.txt" is in the list if "myfile.txt" in files_and_directories: print("File found!") else: print("File not found.")
Result:
Report an issue