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.

Writing a function in python that finds the longest word in a

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!