Python program to Display Error Message for Non-Existed Files

fp = input("Enter file path: ") try: file = open(fp) except FileNotFoundError: print("Error! This file path does not exist...") else: print(file.read())

 

 

Output:

 

Enter file path: c:/python.txt
Error! This file path does not exist...