Question: Define a function strW changedChar(...) that receives three parameters: a string ( orig ) and two characters ( ch1 and ch2 ). The function should

Define a function strWchangedChar(...) that receives three parameters: a string (orig) and two characters (ch1 and ch2). The function should return a NEW STRING containing the same characters as in the original string (orig) except that in those positions where the character ch1 is in the original string the new string should have the character ch2. If the character ch1 is not present in the original string then the new string to be returned should be the same as the original string. Lower case or upper case are not changed.

As an example, the following code fragment:

print (strWchangedChar("---1--1-1--","1","2"))

should produce the output:

---2--2-2--

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!