Question: Python Exercise Replace Objectives: Practice string manpulation with loop. Write a function, named replace, that has three parameters: (1) a string named original, (2) a
Exercise Replace Objectives: Practice string manpulation with loop. Write a function, named replace, that has three parameters: (1) a string named original, (2) a single-character string, named old, representing the character to be replaced, (3) another single- character string, named new, representing the character to be used for replacement. The function should return a new string where every occurrence of old in the passed-in string is replaced by new. You should write a loop to implement such a functionality. You might want to use the following test cases: Function cal Return value "He**o replace ("Hello", "1",*) replace ("this is a test","," ") replace ( " " , "X", "y") replace ("no change", "i"" "this is_a_test" "no change
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
