Question: Using python Write a recursive method that takes 1) a string to find a string, 2) a string to replace the found string with, and

Using python Write a recursive method that takes 1) a string to find a string, 2) a string to replace the found string with, and 3) an initial string. Return the initial string with all the found strings replaced with the replacement string. You may not use loops or the built-in string methods except comparison, length, and slicing. Here is an outline.

def findandreplace(find, replace, string): ''' Replace all instances of find with replace in string. Recursive approach: If the string starts with find return replace and call findandreplace with the rest of the string else return the first character of the string and call findandreplace with the rest of the string ''' pass

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!