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.
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:
Comments
Dear Alok S, Questions in this section are answered for free. We can't fulfill them all and there is no guarantee of answering certain question but we are doing our best. And if answer is published it means it was attentively checked by experts. You can try it yourself by publishing your question. Although if you have serious assignment that requires large amount of work and hence cannot be done for free you can submit it as assignment and our experts will surely assist you.
Its not passing the cod
Leave a comment