Example:
Input:
str = 'He00l wlrod!'
ch1 = 'l'
ch1 = 'o'
Output: 'Hello world!'
In the below solution, we will use a map() function and lambda expression to replace the characters within the given string. There will be a string (str), and two characters (ch1, ch2), by using the combination of the map() and Lambda expression, we will replace the characters i.e., ch1 with ch2 and ch2, other characters will remain the same.
Python code to replace characters using map() function and Lambda expression
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer