Question: use Python def count_pattern(str, pattern, replace_str): assert len(str) >- len (pattern) # complete the function Complete the above function which takes three string variables as
use Python

def count_pattern(str, pattern, replace_str): assert len(str) >- len (pattern) # complete the function Complete the above function which takes three string variables as input, and replace all substrings in the first string that matches a given pattern specified by the second input with a given substitute string specified by the last input, and return this updated string as output. For example, count_pattern('shjhfdddedaaba''xyx, 123') returns 's123fdd123a123' as there are three substrings in the first string that match the given pattern: 'hjh', 'ded', 'aba'. Note: You should assume the initial string to be fixed, and create a new string to replace the existing substrings. 5 ptsl
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
