String Replacement Function

  • Share this:

Code introduction


This function takes two arguments: the original string to be replaced and the target string to replace with. The function returns a new string where all occurrences of the substring from the original string are replaced with the target string.


Technology Stack : String manipulation

Code Type : String replacement

Code Difficulty : Beginner


                
                    
def string_replace(arg1, arg2):
    """
    Replace all occurrences of a substring in a string with another substring.
    """
    return arg1.replace(arg2, '')