I'm working on a program that accepts a file name as an input, I'm trying to add an error check so that when an invalid file is entered it doesn't break the program, but I'm not quite sure how to do it.
Currently I'm just using
image1 = Image.open(raw_input('Enter your first image name: '))
Essentially what I need is some type of loop in the event that a file isn't there. For example the file I'm using is june_subset_gray.tif, but if someone wrote jne_subset_gray.tif rather than prompting them to try again it would just break. Also I don't want to hard code what it could be because something could name their file picture.jpeg, or alaska.tif.
With that said I'm guessing I'm looking for something that will loop in the event that the file being called doesn't exist.
Thanks for all the responses in advance. This wasn't covered in my programming class at all so I'm at the mercy of google and stackoverflow.