MIT 6.00 Intro Computer Science (OCW) 32 Online
OpenStudy (anonymous):

I'm really having trouble with Problem 1 in set 3. I'm using the result of a find as my test in the recursive function but it's not working.

OpenStudy (anonymous):

def recursion(target, key, ans=()): print find(target,key) if (find(target,key)) ==-1: return ans while find(target,key) != -1: ans += (len(target),) print ans recursion(target[find(target,key)+len(key):], key, ans) is what I'm using, but even when find(target,key) == -1, it still doesn't trigger the following if statement.

OpenStudy (anonymous):

I'm using this as a recursive function within my solution. it's meant to return a tuple called ans that lists the successive lengths of the target string as it's shortened. from that I can determine the number of finds in the original string and their locations. I suspect there's a better way, but I'm not that bright.

OpenStudy (anonymous):

nvm, I've got something I'm happier with.

Latest Questions
kimberlysaavedra: Sea world pics
37 minutes ago 8 Replies 1 Medal
luvnickk: heyyy
5 hours ago 4 Replies 0 Medals
kimberlysaavedra: DOLPHIN
13 hours ago 24 Replies 0 Medals
ShikuniShigana: Am halfway yall, this the redrawn version of the original post i did
1 hour ago 23 Replies 2 Medals
xXAikoXx: I wanna cry so bad
7 hours ago 30 Replies 2 Medals
kimberlysaavedra: guyss its my birthday tomorrow!!!!!! 8-4-2008
8 hours ago 16 Replies 1 Medal
TarTar: If you could go back to any year what would you pick and why
3 hours ago 26 Replies 3 Medals