Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can we use the split() and join() method instead of replace method to solve this problem? We are only allowed split(), join() and not

How can we use the split() and join() method instead of replace method to solve this problem?

image text in transcribedWe are only allowed split(), join() and not replace

1 Write a function called "replace all" that accepts three Traceback (most recent call las 2 #arguments: File "ReplaceAll.py", line 47, print(replace_all(target, fi 22, new str-target.replace(tar 4 #-target-string, a string in which to search. 5 #-find-string, a string to search for. in 6 #-replace-string, a string to use to replace every instance of the value of find. nd, replace)) File in replace_all "ReplaceAli.??", line 9 #The arguments will be provided in this order. Your function 10 #should mimic the behav 11 #that function in your implementation. Instead, you should 12 #find the result using a combination of split() and join (), 13 or some other method 14# 15 #Hint: This exercise can be complicated, but it can also 16 #be done in a single short line of code! Think carefully about 17 #the methods we've covered. 18 19 of "replace", but you cannot use get string, find_string,replace_s TypeError: "str' object cannot b Command exited with non-zero sta tring) e interpreted as an integer tus 1 2 def replace aintarget sering, find string.replace string) function herel 23 24 25 26 27 28 29 30 32 34 35 #Below are some lines of code that will test your function. 36 #You can change the value of the variable (s) to test your 37 #function with different inputs. 38 # 39 #If your function works correctly, this will originally 40 #print : "In case I don't see ya, bad afternoon, bad evening, 41 and bad nightl" 42 target = "In case I don't see ya, good afternoon, good evening, and good night!" 43 find"good" 44 replace"bad" 45 print (replace_all target, find, replace)) 46 47

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

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

LO1 Understand risk management and identify its components.

Answered: 1 week ago