Python- how to use while loop to return longest line of code
Question: I just started learning python 3 weeks ago, I apologize if this is really
basic. I needed to open a .txt file and print the length of the longest line
of code in the file. I just made a random file named it myfile and saved it to
my desktop.

    
    
    myfile= open('myfile', 'r')
    line= myfile.readlines()
    len(max(line))-1 
    #the (the "-1" is to remove the /n)
    

Is this code correct? I put it in interpreter and it seemed to work OK.

But I got it wrong because apparently I was supposed to use a while loop. Now
I am trying to figure out how to put it in a while loop. I've read what it
says on python.org, watched videos on youtube and looked through this site. I
just am not getting it. The example to follow that was given is this:

    
    
    import os
    du=os.popen('du/urs/local')
    while 1:
       line= du.readline()
       if not line:
            break
       if list(line).count('/')==3:
             print line,
    


Answer: 
    print max([len(line) for line in file(filename).readlines()])
    

