Question: PYTHON: Check if file exists: This code will determine if a file exist or not on the defaultdirectory: import os.path filename = input(What test file
PYTHON: Check if file exists:
This code will determine if a file exist or not on the defaultdirectory:
import os.path
filename = input("What test file to open? ")
if os.path.isfile(filename):
print ("File exist")
else:
print ("File not found")
Use the "Try" and "Except" exception to write the same code.
Step by Step Solution
There are 3 Steps involved in it
To use the try and except exception to check if a file exists you can use the following co... View full answer
Get step-by-step solutions from verified subject matter experts
