Question: def recursiveSubstring(s, sub): ''' The parameters sub and s are strings. This function computes if the string sub exists in s. - Your solution must
def recursiveSubstring(s, sub): ''' The parameters sub and s are strings. This function computes if the string sub exists in s. - Your solution must use recursion in order to receive credit. ''' if len(s) < len(sub): return False elif s[:len(sub)] == sub: return True recursiveSubstring(s[1:],sub)
This python function must determine if the subString is in s, recursively. This is my solution, which only works if the substring is in the first characters of s. What is a recursive solution to the function recursiveSubstring?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
