Write a program to find and print all words which are less than a given length in a string
Topic: Write a program to find and print all words which are less than a given length in a string
Solution
str1 = "It is wonderful and sunny day for a picnic in the park" str_len = 5 res_str = [] text = str1.split(" ") for x in text: if len(x) < str_len: res_str.append(x) print("Words that are less than " + str(str_len) + ": " + str(res_str))
List all Python Programs