Question #175077

string A is "Tea is good for you", k is 3 then output should be "is good."

Here words "Tea", "for", "you" length is equal to 3, so these words are removed from string.


Expert's answer

strin='Tea is good for you'
newStr=strin.split(' ')
new2=newStr[1]
new3=newStr[2]
joined=new2+' '+new3
k=input('enter the vaue of k= 3 \n')
if(int(k)==3):
    print(joined)
    if(int(k)==3):
        text = strin.replace('is good', "\b")
        print("\nNew String without \"" + joined + "\":")
        print(text)
    else:
        print("\n\"" + joined + "\" is not found in the string!")

Output:


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS