Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions