Question: Writing a function in python that finds the longest word in a text file. The only punctuation used is ,.!?; I want to inclue somewhere
Writing a function in python that finds the longest word in a text file. The only punctuation used is ,.!?;
I want to inclue somewhere a .strip function to strip the text file of these punctuation symbols but am having trouble with it. I am aware of the .strip restrcitions and want to use this function in my code.

def longestWord(filename): maxword = '' with open(filename, 'r') as x: for line in x: linelist line.splitO for word in LineList: if len(word) > maxwordlength: maxwordlength = len (word) maxword word return maxword
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
