A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing


  • 5 years ago

problem set 3a, I can't come up with a way to finish off my recursive part of my function. So far I have: def countSubStringMatchRecursive(target,key): if (find(target,key) < 0): return 0; return 1 + countSubStringMatchRecursive(target[find(target, key)],key); i feel like i should replace the 1 in the return statement with the function.

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Think about what your trying to do. You found the key in the target. Now what you want to do is to renew the search, in the substring(which is the string starting from where you find the key until the end of the target string) also keep in mind that you need to keep track of every instance you find the key string. If you have problems with that, or again with the code. post again and we'll help you.

  2. carlsmith
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I always find it easier to draw the recursion if I'm struggling with visualising the process. A quick block diagram, with each nested block indented, like regular Python blocks, works for most stuff in practice. [ start ] [ next ] [ next ] Just scribble it on paper and have a look at it. You'll find you've got it sussed before you've drawn very much of it. Don't try and go on like Michaelangelo.

  3. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...


  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.