I need to create a loop that prompts a user to enter a file name that they wish to be processed. If the file does not exist, an error message should show up saying "The file (filename) does not exist!". After the error message is prompted to the user the loop should ask the user to enter the name of a file they wish to be processed or to exit the program.
loop = 'y'
while loop == 'y':
filename = input("Enter the name of the file you wish to process?: ")
if FileNotFoundError is True:
print("The file" + filename + "could not be found!")
quit = input("Enter the name of the file you wish to process or type exit to quit: ")
if quit == 'exit':
loop = 'n'
I'm stuck in the first part of the loop. I'll input a file that either exists or not and it will just keep asking me the file I wish to process. I'm also sure that the following code is a longer version of a try except block that probably does not work. New to python and coding in general so this seems like a noob mistake.