Computer Science, asked by Anonymous, 10 days ago

WAP to count no . of words with length <=4 in a given sentence in python

Answers

Answered by shrihankp
1

Answer:

def count_words_with_length_lte_4(string):

wlist = string.split(" ")

count = 0

for word in wlist:

if len(word) <= 4:

count += 1

return count

line=input("Enter a line: ")

print("Number of words with length <= 4: " + count_words_with_length_lte_4(line))

Similar questions