Hi I am learning python by doing the practice problems for Open course at MIT 6.00 Intro to Computer Science.
I am Trying to do practice problem 1 part 2 create a recursive function to count the instance of key in target. My code so far...
from string import *
def countSubStringMatchRecursive (target, key,x,s):
if (find(target,key)==find(target,key,s)) and (find(target,key)==find(target,key,(find(target,key)))):#if first and last
return (1)
elif (find(target,key)==find(target,key,s))and (find(target,key)!=find(target,key,(find(target,key)))):#if first but not last
x=1
s= find(target,key)
return (countSubStringMatchRecursive(target,key,s,x)
elif (find(target,key,s))==-1 and (find(target,key)!=find(target,key,s)):#if last but not first
return (x+1)
elif:(find(target,key,s))!=-1 and (find(target,key)!=find(target,key,s)):#if not last and not first
x=x+1
s= find(target,key,s)
return (countSubStringMatchRecursive(target,key,s,x)
I getting a syntax error at line 8. I would just like to know what I did wrong there. Dont worry about the other mistakes I should be able to get those sorted out. I just Stuck on this. Thanks.