Question: Please fix this error in Python. Here was the assignment. from sys import argv def longest_ word(fn_input): file_inputopen (mary.txt, r) maxLength0 maxWord = for

Please fix this error in Python. Here was the assignment. from sysimport argv def longest_ word(fn_input): file_inputopen (mary.txt, "r") maxLength0 maxWord = ""Please fix this error in Python. Here was the assignment. for line in file_input: for word in line.split(" "): if maxlength len

from sys import argv def longest_ word(fn_input): file_inputopen (mary.txt, "r") maxLength0 maxWord = "" for line in file_input: for word in line.split(" "): if maxlength len (word): maxLengthlen (word) maxWord -word return maxword if _name_ "main__"; fn-in-argv [1]1 print(longest_word(fn_in)) In [17]: runfile ("/Users/Jay/Desktop/LAB/ untitled1.py', wdir- /Users/Jay/Desktop/ LAB') Traceback (most recent call last): File "", line 1, in runfile("/Users/Jay/Desktop/LAB/ untitled 1 . py. LAB') wdir-'/Users/Jay/Desktop/ File "/anaconda3/lib/python3.7/site packages/spyder_kernels/customize/ spydercustomize.py", line 704, in runfile execfile(filename, namespace) File "/anaconda3/lib/python3.7/site packages/spyder_kernels/customize/ spydercustomize.py", line 108, in execfile exec(compile(f.read(), filename, 'exec) namespace) File "/Users/Jay/Desktop/LAB/ untitled1.py", line 22, in fn inargv [1] IndexError: list index out of range 1. (10 Points) Write a program that prints the word that has the longest length, in terms of the number of characters, in the supplied text file. Show your output to the TA on the following text files: mary.txt and frost.txt

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!