String Attribute
John Strick
jstrickler at gmail.com
Wed Jul 29 16:46:12 EDT 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 '):
continue
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().
--john
More information about the Python-list
mailing list