Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 ptslStep 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