Find the integer representing the last sub-string of a string
Well the short answer would be str.rfind().

&gt;&gt;&gt; find_last = lambda s, t: s.rfind(t)
&gt;&gt;&gt; find_last("aaaa", "a")
3


Though I'm not sure how much you're required to implement yourself. (Does the task allow usage of .find() at all?) Maybe it could be written like this:



def find_last(s, t):
    start = 0
    while True:
        if s.find(t, start) &lt; 0:
            return start - 1
        start += 1




def find_last(s, t):
    for i in range(len(s)-len(t), -1, -1):
        if s[i:i+len(t)] == t:
            return i
    return -1