Answer to Question #231266 in Python for bhuvana

Question #231266

Given a string, write a program to remove all the words with K length


1
Expert's answer
2021-09-06T00:16:33-0400
def toString(sen): 
    s1 = "" 
    for e in sen: 
        s1 += e  
    return s1 


def remove(sen, n):
    n_w = []
    ws = sentence.split(" ")
    for w in ws:
        if not len(w) == n:
            n_w.append(w)
            n_w.append(" ")
    return toString(n_w)




a = str(input("Enter a sentence:"))
n = int(input("Enter lenth to remove):"))
print(remove(a, n))

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS