0
Give explanation to this practical question
PRACTICE EXERCISE Imagine you're creating content for a vocabulary-building app. You want to challenge users by showing them only the longer words from a provided list.
3 Antworten
+ 1
What do you mean?
Do you not understand the task?
You need to check the length of the words and then only select the longer ones to output.
0
This is the answer
words = ["tree", "button", "cat", "window", "defenestrate"]
# Use a list comprehension to filter out words longer than four letters
long_words = [word for word in words if len(word) > 4]
# Display the filtered list
print (long_words)