Why doesn't my code work?

Curious why my code didn’t work. I must be missing something in the fun. Could not solve for ‘pl’

def substring_between_letters(word, start, end):
  if word.find(start) < 0 or word.find(end) < 0:
    return word
  else:
    word[word.find(start)+1:word.find(end)]

Why not just use:

You also forgot the return in your else.

In the hint they tell us this:

Begin by finding the indices of the start and end characters by using word.find(start) and word.find(end) .

If either of those indices are -1 , then the original string didn’t contain one of those characters, and you should return word .

This is why a lot of us try to do this that way. I personally used your way cause I don’t even understand the reasoning behind a hint, since -1 is the last index on a list but here they claim -1 means that it’s not on a list.