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.
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=' ')
Comments
Leave a comment