• "GOES RIGHT AFTER"

 

Hi,

Things went pretty well until the 2 last challenges. One of them is the "Goes right after" i've tried to search around to understand this piece better, but for some reason i just cant understand it.

One of the possible solutions to this task is:

def goes_after(word: str, first: str, second: str) -> bool:

return -1 < word.find(first) == word.find(second) - 1

This part:

word.find(first) == words.find(second)

.find method returns the index of first occurrence of the substring. So this code looks into the "word", returns whatever "first" is (And if there is, otherwise it returns -1?), then it sets this equal (for some reason?) to the "second" parameter.

So why we set it to equal and then why we use the ( -1 < ) and the ( - 1 ) at the end is for me a bit confusing.

Let's say the word is "world" and the parameter "first == w" and "second == o)

This means that we now have:

-1 < w == o - 1

well i dont know. This was something new for me.

.