Working on ps3 problem 1 (the iterative function): I think I have the basic idea of how it works but my code is doing something funny. Any clues on how to tweak it to make it work would be much appreciated. http://codepad.org/lRGrwQFQ
So I think I actually fixed it. But there has to be a better way. Any suggestions?
Uhm, if you made changes, can you post the updated code?
You probably already noticed, but you may begin subsequent searches at the index of the match+1. For example, the first find of "a" in "banana" will return 1. You may then set your next search up to begin at index 2. Something similar to this: http://codepad.org/aLhvRQuV
kgiax: I thought I did, but I misunderstood how codepaste works. Here is what I came up with to fix it: http://codepad.org/YOc7FM6n
walkerp1: I think my fix does that, but not as elegantly. I think there is some redundancy in the n and x of my current code.
kgiax + walkerp1: newest and I think final verison: http://codepad.org/g5GtrURI Last question regarding this. When "print codeSubStringMatch("anything","key")" is put in, why is it returning None after the "There are x instances...They are..."?
you need to return something at the end of your function like return matches you can return multiple things return matches, matchesLoc here is another way to keep the while loop going http://ideone.com/OcPXU
Join our real-time social learning platform and learn together with your friends!