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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started