Q. Write a function file_long() that accepts a filename and reports the file's longest line.


Answer =

 

def file_long (filename) :
    longest = ""
    for line in open (filename):
        if len (line) > len (longest) :
            longest = line
    print ("Longest line length = ", len (longest))
    print(longest)


Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post