Write a Python program to find the list of words that are longer than n from a given list of words


This program takes an input n which represents the minimum length of a word. The program then takes a string of words and uses the split() method to separate the string into a list of words. It then iterates through each word in the list and checks if the length of the word is greater than n. If it is, the word is added to a new list called new_list. Finally, the program prints out the new_list which contains all the words from the input string that have a length greater than n.

Source Code

n=4
str="Find the List of Words that are Longer than n from a given List of Words"
new_list = []
text = str.split(" ")
for x in text:
	if len(x) > n:
		new_list.append(x)
print(new_list)

Output

['Words', 'Longer', 'given', 'Words']

Example Programs