Advertisements
Advertisements
Question
Write a Python function that finds and displays all the words longer than 5 characters from a text file "Words.txt".
Code Writing
Solution
def display_long_words():
with open("Words.txt", 'r') as file:
data=file.read()
words=data.split()
for word in words:
if len(word)>5:
print(word,end=' ')
shaalaa.com
Is there an error in this question or solution?