Answer to Question #329868 in Python for Mamatha

Question #329868

Input: Tea is good for you


3


Output:is good



Explanation: given a string write a program to remove all the words with k length.

1
Expert's answer
2022-04-17T15:30:38-0400
 data = input("Please enter your text: ").split(' ')
k = int(input("Please enter K: "))
shift = 0
for i in range(len(data)):
    if len(data[i - shift]) == k:
        data.pop(i - shift)
        shift += 1
    else:
        print(data[i-shift], end=' ')

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