lst = [1]
txt = 'testing'
try:
return txt.index('z') + lst[1]
except IndexError as e:
# I don't know if this is because of the list or string...
# (but in this case I probably don't care - I just can't work with the input(s))
# If I did though...
try:
idx_txt = txt.index('z')
except IndexError:
# okay - something wrong with the string
# can I do something here...?
# if not re-raise or raise something more specific
try:
value = lst[1]
except IndexError:
# as above...