I have the following code:
def subStringMatchExact(target,key,matches=(),base=0):
if find(target,key) != -1:
matches += (find(target,key)+base,)
base += find(target,key)+len(key)
subStringMatchExact(target[find(target,key)+len(key):],key,matches,base)
else:
print matches
return matches
When I run the function, say for instance subStringMatchExact('abcdabcdababcdedakcdobcdabcd','abc'), the print matches line will have my interpreter print (0,4,10,24), which is correct. However the line return matches returns value None.
Similarly when I call print subStringMatchExact('abcdabcdababcdedakcdobcdabcd','abc'), the interpreter also gives None.
Can anyone help me correct this?
I rather think that you intended to return the recursive value on line 5. As it is, it just calls it and then continues to the end of the method, returning
None. So, all you need is the insertion of thereturnkeyword.