String Attribute

John Strick jstrickler at
Wed Jul 29 22:46:12 CEST 2015

    fname = raw_input("Enter file name: ")
    if len(fname) < 1 : 
        fname = "mbox-short.txt"
    for line in fname:
        line = line.strip()
        if not line.startwith('From '): 
        line = line.split()
        count = count + 1

You need to actually open the file. (Look up how to do that) The first 'for' loop is looping through the file NAME, not the file OBJECT. Also, line.startwith() should be line.startswith().


More information about the Python-list mailing list