Is there any way to put an optional input into a function in the python version used here? (Problem set 3, problem 1) I created a function def countSubStringMatchRecursive(target, key, location=0) It keeps giving me errors
did you put semicolon after function definition?
you definition should have look like this: def countSubStringMatchRecursive(target, key, location=0): actually, your 'location' parameter is optional; however, if no argument is passed for 'location', the value 0 is used for it
Hello Brownbear. I think I know what you mean - since I remember myself thinking about the same problem. Try putting the location in after find (inside the function itself... find(key,string,location) after as you're actually 'slicing' the string. - remember, we're looking for instances, not locations.
Hey grupiyati. My location variable name references the location at which the search is done, because the find function works like find(target,string,[location to start working from]).
Join our real-time social learning platform and learn together with your friends!