Computer Science, asked by yagrawal581, 6 months ago

Write a python program to read a text file fun.txt & find the longest word.​

Answers

Answered by Anonymous
2

Answer:

  1. Contain of text.txt. ...
  2. Sample Solution:-
  3. Python Code: def longest_word(filename): with open(filename, 'r') as infile: words = infile.read().split() max_len = len(max(words, key=len)) return [word for word in words if len(word) == max_len] print(longest_word('test.

Similar questions