I am making a file open function for the beginning of my program where it prompts the user to input a filename and then it will open that file. I was trying to use the try-except function for this so that if it's a valid file then print it and if its not a valid file to return a filenotfound error. I'm unsure how I can implement the file not found error. This is what I came up with so far:
def open_file():
file = input("Please input a file to use: ")
try:
fp = open(file)
except:
filenotfounderror
I'm pretty sure this should work but I'm not sure what to write in place of the filenotfound error after except