This works:
def find_file_ix(fn,fn_list):
if fn in fn_list:
ix=fn_list.index(fn)
else:
ix=-1
return ix
l=['a','b','c','d','e']
print(find_file_ix('d',l))
print(find_file_ix('z',l))
and prints 3, -1 as expected.
I could accomplish the same thing with a try/except sequence. However, I find both clumsy and the above code seems to have an element of redundancy - surely the 'in' test must have already found the index?