def last_find(txt: str, pat:str) -> int:
    s = len(txt)
    l = len(pat)
    for i in range(s - l, -1, -1):
        count = 0
        for x in range(l -1, -1, -1):
            if txt[i  + x] == pat[x]:
                count += 1
        if count == l:
            return i

    return -1

print(last_find("mississippi", "iss"))

    

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: